How to generate PDB's for .net managed projects in release mode?
Solution 1
In VS2008, you can set the property using the project properties ->
Build ->
Advanced... ->
Debug Info.
Solution 2
In DEBUG:
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
In RELEASE:
<DebugSymbols>true</DebugSymbols>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
Solution 3
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.
Cristian Diaconescu
Getting things done at scale. profile for Cristi Diaconescu on Stack Exchange, a network of free, community-driven Q&A sites http://stackexchange.com/users/flair/6794.png
Updated on July 29, 2022Comments
-
Cristian Diaconescu almost 2 years
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?
-
Cristian Diaconescu about 15 yearsNice! 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!
-
Richard about 15 yearsIn VS 2008 (and maybe 2005) pdb-only is the default for release builds (and full for debug).
-
Daniel P. Bullington about 15 years"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.
-
tster over 10 years@Daniel Bullington, You don't get line numbers and filenames without pdb files, which makes the stack traces at least "less useful"
-
Daniel P. Bullington over 10 years@tster yes I agree, but even without PDBs (and thus line numbers/file names), the stack traces are still useful to lesser degree :)
-
aaaaaa over 6 yearsIf I was handed a release bug that didn't have line numbers or file names with stack traces, I would probably scream "this is useless!"
-
Dave Yarwood over 6 yearsI regularly have to hunt down bugs where all I have to refer to is a stacktrace with file names and method names, but no line numbers. The methods are typically hundreds of lines long, so I have to bisect my way to the problem by moving around a line that says
Console.WriteLine("got here");
. It's a nightmare.