Nils O
Nils O

Reputation: 1321

Visual studio 2013 locking PDB files when debugger is attached

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.

The problem arises when running my project with a debugger attached: during the clean-up I get a system.UnauthorizedAccessException with message

"Access to the path ...\obj\release\CalithaLibrary.pdb denied".

Using sysinternals Process Explorer I found out that the lock was aquired by devenv.exe.

When I build a release version of my project and run it outside of visual studio the problem does not arise.

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?

Edit: The first answer I received made me think I probably wasn't clear enough about the situation:

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.

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.

Upvotes: 3

Views: 1276

Answers (2)

Nils O
Nils O

Reputation: 1321

I'm starting to become pretty sure there's a bug in MSBuild here somewhere.

Luckily I managed to debug the last part of the application I needed to debug by excluding a few of the builds it was making, so it's now running in Release and does not encounter problems anymore.

Some information on why I think it must be a bug.

My application's workflow was something like this:

  • Create a temporary workspace on Team Foundation Server

  • GET a number of solutions/projects from TFS to a temporary folder

  • BUILD a number of these (configurable through xml but that's beside the point) to a different temporary folder

  • Clean up the temporary folder with source code

I tried setting MSBuild Options "DebugType" to none and "DebugSymbols" to false, but for some reason it kept outputting the Program Database files which is why I think there's a bug somewhere.

Whenever I skipped the "Building" step and skipped straight ahead to "Clean up" there were no locks on any files.

Upvotes: 0

Goshutu
Goshutu

Reputation: 132

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.

Well, CalithaLibrary looks like a DLL project, which is most certainly being used when you run AutoReleaseService.exe. It is straightforward - when the exe project is run, it uses all of the dll-s which it depends on. Visual Studio (devenv.exe) locks the .pdb files, because they are the link between the source code and the executable when you debug the application, and if you open the executable from outside of Visual Studio - they are not locked, because you do not need them then.

Upvotes: 1

Related Questions