views:

1504

answers:

3

I know PDBs are generated for managed projects in .NET by giving the compiler the /debug argument. Is there a way to specify this in the VS (2005) GUI?

The only way I could get it to generate PDBs in release mode so far is to manually modify the .csproj file and to add :

<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>

under the 'release' settings:

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">

Another thing: I learned from MSDN here that the possible values for the DebugType tag are:

  • full
  • pdbonly
  • none

How do these values affect the compiler's behaviour?

+1  A: 

I found this MONO request that may shed some light on what's the difference between 'full' and 'pdbonly'.

csc has a "pdbonly" debugtype that generates pdbs, while producing runtime code, i.e. optimised, no debugger attributes, etc.

This is important for being able to obtain useful stack traces from release-quality code.

It seems to me that the existance of the 2 tags (DebugSymbols and DebugType) is redundant.

Cristi Diaconescu
"obtain useful stack traces"This is incorrect. You will always get useful stack traces in .NET code due to the presence of type metadata. The PDBs in release flavor IS important for single-stepping through production code but you may get errors in the debugger due to optimizations.
D. P. Bullington
+2  A: 

In VS2008, you can set the property using the project properties -> Build -> Advanced... -> Debug Info.

Mehrdad Afshari
Nice! I verified it works in VS 2005 as well. I stared at the 'Build' settings a million times, but never noticed that 'Advanced' button.Thanks!
Cristi Diaconescu
In VS 2008 (and maybe 2005) pdb-only is the default for release builds (and full for debug).
Richard
A: 

In DEBUG:

<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>

In RELEASE:

<DebugSymbols>true</DebugSymbols>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
D. P. Bullington