Search code examples
asp.net

How do you stop source file information appearing in a Release?


I am building a web application. Here's what I do.

Set the solution Configuration Manager to Release. Thus all projects are building the Release version. Then I clean the solution and build all. Then I "Build Deployment Package".

When running the installed code from the deployment package I notice when there is a bug in the compiled source the source file appears! How is this possible, I am building the Release configuration. The source code is definitely not in the release so it must be in the dlls.

Is there a way to stop this?


Solution

  • Assuming you are talking about the 'Yellow Screen of Death' ASP.NET error pages, showing the source code locations of the exceptions; that is happening due to including the debug symbols in the build and the deployment package. That is the *.pdb file(s) named the same as your *.dll file(s).

    This is not bad, in and of itself. However, you should not be displaying those errors to end-users regardless. Even without the debug symbols, those error messages show too much information. You should be handling errors and displaying a 'safe and friendly' error message to users.

    If you want to remove the debug symbols, you can remove the PDB files. You can also change the build properties in the project, and remove the option that includes debug symbols.