How to generate PDB's for .net managed projects in release mode?
Asked Answered
Q

3

8

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?

Quarterphase answered 25/2, 2009 at 9:58 Comment(0)
S
7

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

Substantive answered 25/2, 2009 at 10:3 Comment(2)
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!Quarterphase
In VS 2008 (and maybe 2005) pdb-only is the default for release builds (and full for debug).Aleshia
A
8

In DEBUG:

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

In RELEASE:

<DebugSymbols>true</DebugSymbols>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
Adipose answered 3/4, 2009 at 16:35 Comment(0)
S
7

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

Substantive answered 25/2, 2009 at 10:3 Comment(2)
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!Quarterphase
In VS 2008 (and maybe 2005) pdb-only is the default for release builds (and full for debug).Aleshia
Q
5

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.

Quarterphase answered 25/2, 2009 at 10:1 Comment(5)
"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.Adipose
@Daniel Bullington, You don't get line numbers and filenames without pdb files, which makes the stack traces at least "less useful"Selfesteem
@Selfesteem yes I agree, but even without PDBs (and thus line numbers/file names), the stack traces are still useful to lesser degree :)Adipose
If 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!"Whichever
I 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.Gregor

© 2022 - 2024 — McMap. All rights reserved.