title: Visual studio 2013 locking PDB files when debugger is attached
body: <p>I'm working on a project that retrieves a number of Solutions from a team foundation server, to a temporary folder, uses Microsoft.Build.Execution.BuildManager.Build to build a release version for these Solutions, and cleans up the temporary folder with source code afterwards.</p>
  
  <p>The problem arises when running my project with a debugger attached: 
  during the clean-up I get a system.UnauthorizedAccessException with message </p>
  
  <blockquote>
    <p>"Access to the path ...\obj\release\CalithaLibrary.pdb denied".</p>
  </blockquote>
  
  <p>Using sysinternals Process Explorer I found out that the lock was aquired by devenv.exe.</p>
  
  <p>When I build a release version of my project and run it outside of visual studio the problem does not arise.</p>
  
  <p>Any ideas as to why Visual Studio would aquire a lock of a PDB belonging to a project that was never opened by Visual Studio?</p>
  
  <p>Edit: The first answer I received made me think I probably wasn't clear enough about the situation:</p>
  
  <p>I'm debugging a project named "AutoReleaseService.exe" which uses Microsoft.Build.Execution.Buildmanager to build (but not run or debug!) a number of other projects, among which CalithaLibrary.</p>
  
  <p>If I were trying to delete the AutoReleaseService.pdb from my own project, to which I did, in fact, attach the debugger, I'd understand, but the project to which the pdb file that gets locked belongs hasn't even been run on my machine, let alone debugged. I only built the project.</p>