What is a PDB file and how can I exclude it from the release folder when I rebuild my solution?
-
25pdb is a program database file and it is created on compile. This file holds debugging and project state information that allows incremental linking of a debug configuration of your program.– pavanredOct 10, 2010 at 8:40
-
@pavanred are you sure C# compiler also does incremental linking? I've only heard about it in C++ world. In a C++ project you enable/disable incremental linking from project properties. Is there an option in C# project also?– RBTOct 27, 2016 at 8:30
5 Answers
A PDB file contains information for the debugger to work with. There's less information in a Release build than in a Debug build anyway. But if you want it to not be generated at all, go to your project's Build properties, select the Release configuration, click on "Advanced..." and under "Debug Info" pick "None".
-
4@Jon Does it help provide extra information to the user if the application crashes in use? (ie, does it help with the JIT window, rather than "This program needs to end, send a Windows Error Report") Oct 10, 2010 at 8:32
-
27Bear in mind that you should probably keep these included in your debug releases, as it allows exceptions to be traced to a specific line in your code. Without the symbols in the pdb file, you will find it hard to pinpoint specific problems in order to solve them. You don't necessarily need to exclude them from release builds either, as sometimes the extra information in a big report can be very useful.– DarbioOct 10, 2010 at 8:37
-
4@Jared: Yes, it includes a stack trace of the exception, which will pinpoint to a specific function and line of code.– DarbioOct 10, 2010 at 8:40
-
1@Jared: What do you mean by "the JIT window"? It's unlikely to give much more information to the user, but it may let you attach a debugger to a release build if you need to. Typically you wouldn't include it for end-user applications though. Of course, just because it's copied to the Release folder doesn't mean you have to ship it in the installer... Oct 10, 2010 at 8:41
-
3@Ata: PDB, not PDF. Please separate the two in your mind - they're completely different file formats, for different purposes. Including a PDB wouldn't introduce a problem particularly; it may make a hacker's job slightly easier, but is that a particular concern for you? In general, .NET can be decompiled relatively easily in most cases - if you're worried about that, simply not shipping the PDB isn't a good solution. Oct 10, 2010 at 8:55
I had originally asked myself the question "Do I need a PDB file deployed to my customer's machine?", and after reading this post, decided to exclude the file.
Everything worked fine, until today, when I was trying to figure out why a message box containing an Exception.StackTrace
was missing the file and line number information - necessary for troubleshooting the exception. I re-read this post and found the key nugget of information: that although the PDB is not necessary for the app to run, it is necessary for the file and line numbers to be present in the StackTrace
string. I included the PDB file in the executable folder and now all is fine.
-
13This is a very important part to keep in mind which the
accepted answer
here doesn't mention.– MonkuNov 29, 2019 at 19:33
PDB is an abbreviation for Program-Debug Data Base. As the name suggests, it is a repository (persistent storage such as databases) to maintain information required to run your program in debug mode. It contains several vital information required for code debugging e.g. at what points you have put break points where you expect the debugger to break in Visual Studio (VS).
This is the reason why Visual Studio fails to hit the break points if you remove PDB files from the debug directory. Visual Studio debugger is capable of telling you the exact line number of code file at which any exception occurred along with its stacktrace. It is able to do so with the help of PDB files only. Thus PDB files are very helpful for debugging purposes.
In general, it is not recommended to exclude the generation of PDB files during build process. From production release stand-point, what you should be doing is create the PDB files but don't ship them to customer site in product installer. Preserve all the generated PDB files on a symbol server from where it can be used/referenced in future if required.
It is specially important in scenario where you debug process crash issues. While analysing the crash dump files, Visual Studio will not be able to make out the exact line of code where program is crashing if the original PDB files created during the build process were not preserved.
If you still want to disable generation of PDB files then follow below steps:
- Go to properties window of the project. To open properties window, select the project file in solution explorer and press Alt + Enter.
- Go to Build tab
- Click Advanced
- Choose none from Debug Info drop-down box
- Press OK as shown in the snapshot below:
Note: This setting will have to be done separately for Debug and Release build configurations.
A PDB file contains information used by the debugger. It is not required to run your application and it does not need to be included in your released version.
You can disable pdb files from being created in Visual Studio. If you are building from the command line or a script then omit the /Debug
switch.
-
3Release mode still builds PDBs by default, I believe. You can change the project properties to disable it though. Oct 10, 2010 at 8:28
-
-
I just checked and I also get one by default if using Visual Studio. Oct 10, 2010 at 8:33
-
Surprise! Somewhen in the last 11 years, that PDB link went stale. Here's the new link: wintellect.com/pdb-files-what-every-developer-must-know Mar 26, 2021 at 21:36
Program Debug Database file (pdb) is a file format by Microsoft for storing debugging information.
When you build a project using Visual Studio or command prompt the compiler creates these symbol files.
Check Microsoft Docs