Visual Studio Creating Debug File In Release Mode

I asked a similar question a while ago Error Creating Debug Information - Code Won't Compile but never found a solution.

That problem seems to have evolved a bit. Now Visual Studio is creating a PDB debug file even when the application is in Release mode and debugging is turned off in Web.config. This PDB file is getting locked by Visual Studio and sometimes w3wp.exe. Compiling fails saying the PDB file is in use by another process (devenv.exe, w3wp.exe, or both). I cannot compile until I use Unlocker to release all the locks.

First off why is VS creating a debug file when in release mode?

Secondly how can I fix this? I have run a repair install on VS and re registered ASP.Net with IIS but that didn't help. I am using Windows Server 2003, VS 2008 Standard, and IIS6.

The first symptoms showed up a week or two ago when I was working on a WPF application. Until today putting the project in Release mode made the problem go away. Now it is happening even in Release mode.

Any ideas?

13.10.2009 18:53:51

Did you try this:

You can also add custom after-build event to release configuration to delete the pdb file if everything else fails.

13.10.2009 18:59:12
I am down voting this answer because the link does not work and the contents of the link is not posted in this answer. This is one of the reason why SO does not appreciate a link as an answer. It would have been nice if the content of the link, i.e the actual solution have been posted as answer.
Birey 14.05.2014 16:05:54

PDB files are created for release builds too - that is by design so you can still debug crashes in a release binary.

The PDB file is certainly not required for running. However, if it is in the same directory as the binary being run, IIS may be loading it (not really sure what IIS does here though). You can copy the binaries to a different folder (minus the PDB files) to prevent this problem.

13.10.2009 19:06:20