Program Debug Database files in a Release output folder - c#

I've switched over my solution's Build configuration to Release mode and now have an output in the "Release" folder instead of in the "Debug" one.
But still the Release output contains Program Debug Database files. Why is that? When should I keep them, when and how should I get rid of them?

The debug database files (.pdb or "symbol files") contain debug information, such as line numbers, to enable easier debugging.
When present, exception stack traces will contain the actual source file full path and line number.
It is up to you whether to distribute these along with your application.
In order to not create pdb files in Release configuration:
Go to your project's Properties.
Under "Build" tab, select "Advanced" (on the buttom).
For "Debug Info", select "None".
Note that this will not affect any references assemblies (their .pdb files will be copied to your project's output folder.
Read more about Symbols here: Program Database Files (C#, F#, and Visual Basic)

I guess it would be no difference if you deploy your application without these program debug databases as these files could be of great size.

Related

What is the difference between a dSYM folder and an mSYM folder?

I am working on an Xamarin.iOS application that is crashing when being deployed via an Ad-hoc process. As documented by Apple, when an application crashes, a .crash file is generated. The document also states that, as a developer, we must keep the dSYM folder.
Turns out, in my case, I (only?) have a mSYM folder.
Question
What is the difference between an MyApplicationName.App.dSYM folder and a MyApplicationName.App.mSYM folder?
.dSYM
A dSYM file is a "debug symbols file". It is generated when the "Strip Debug Symbols" setting is enabled in the build settings of your project.
When this setting is enabled, symbol names of your objects are removed from the resulting compiled binary (one of the many countermeasures to try and prevent would be hackers/crackers from reverse engineering your code, amongst other optimisations for binary size, etc.).
dSYM files will likely change each time your app is compiled (probably every single time due to date stamping), and have nothing to do with the project settings.
.mSYM
mSYM means MonoSymbolArchive.It contains debug info of mono.
Edit the iPhone release configuration in the csproj file to include <MonoSymbolArchive>True</MonoSymbolArchive> which will generate symbol data in bin/iPhone/Release/.mSYM

Debugging with Pdb file and Source Code File in Visual Studio

I have a web project that posts from client-side code to a method in external dll, which I have source code file and pdb file of this external dll. What I would like to do is to debug external dll using source code file and pdb. Visual studio does not stop to say no symbols are loaded for the module since.
To debug a a symbol file with the same version is always needed. When you are debugging your own applications you usually don't have to care about this.
But there are things happening in the background. Visual Studio always puts the symbol files in the debug folder when you build your application and also loads them as described under Loading the symbols automatic.
(When you distribute your application you usually do not want to distribute those symbols and therefore they won't be copied to the release directory you change your build configuration to release.)
Loading the symbols manually
If you want to load the symbols manually you can load them with the Modules dialog.
"Debug" -> "Windows" -> "Modules".
You can right click a row and there is the option "Load Symbols" which lets you specify a PDB file to load.
Loading the symbols automatically
Visual studio also loads the symbols automatically when they can be found in one of the the places listed in the Specify Symbol (.pdb) and Source Files in the Visual Studio Debugger documentation:
The location that is specified inside the DLL or the executable file.
(By default, if you have built a DLL or an executable file on your computer, the linker places the full path and file name of the associated .pdb file inside the DLL or the executable file. The debugger first checks to see if the symbol file exists in the location that is specified inside the DLL or the executable file. This is helpful, because you always have symbols available for code that you have compiled on your computer.)
.pdb files that could be present in the same folder as the DLL or executable file.
Any local symbol cache folders.
Any network, internet, or local symbol servers and locations that are specified on, such as the Microsoft symbol server if enabled.
If you want to read more about how the symbols are used with visual studio you can read this article about Understanding symbol files and Visual Studio’s symbol settings.

Remove unnecessary files from release directory

I use NSIS to create an installer for my project. Wishing to have as small a filesize as I can, I began looking into my project's dlls, included files and prerequesites and noticed the following are all different:
the minimal files required to run, as determined by educated guess + trial and error. I made sure the application works properly with this minmal set of files.
the files exported by the "Publish" fonction for click once deployment (excluding click once specific files)
the files in the release directory (excluding the pdb and vshost files)
It seems VS2015 generates an xml file for every dll. Some dlls I don't use and don't reference are copied as well.
My question is why is there so many unnecessary files and how can I configure VS2015 to not have them in /release?
If you set VS build log level to verbose you will see exactly what happends during build and why a file goes to release folder. Once you determine the reason, you may either change your project file to adjust predefined behavior or add post-build event to remove unwanted files produced by build process.
MSBuild file, located at "C:\Program Files (x86)\MSBuild\12.0\Bin\Microsoft.Common.targets" is very useful to dig into build process details as well.
However, if you indend to distribute the content of release folder to other machines I'd suggest you look at some installation software, like Wix, for example. Once you create a setup project which includes files you do want, there will be no need to fight for release folder content.

Visual Studio Express 2012 not building exe in Release folder

I have compiled a simple 'Hello World' program. The program is successfully compiled without any errors. I can see a working executable in bin folder. But the Release folder of the project is totally empty.
I don't know if there is any settings problem or any problem in building. Apparently, I don't see any error.
You can change your build mode in top of your Visual Studio:
Dependently on which mode you build your solution, Visual Studio will generate .exe in either bin\Debug folder or bin\Release folder.
Make sure you're building the release version, not the debug version. By default, VS will build a Debug build, which will go into the bin\Debug folders.
For details, see How to: Set Debug and Release Configurations.
More expanded explanation:
Your output directory of executable file is specified by default to [your_project_directory]\bin\Debug for Debug build mode or to [your_project_directory]\bin\Release for Release build mode
your_project_directory - place where is created your project (there is located *.csproj file)
To switch between default directories Debug/Release use solution proposed here.
But if you want specify your own output directory, follow these steps:
Go to Project -> [MyProjectName] Properties... (or type Alt+F7) and in properties window switch to Build tab (from left panel)
From Configuration combobox select proper build mode (in your case Release) or select: "All Configurations" - the same options for both build modes
At the end in output path textbox choose folder where you want store executable file (and other created during buil of application)
Screenshot from properties window:
This solution can be useful at least in two cases:
When are you learning and you want not waste space on your disc, then you can specyfy outbut file for all your project to one tmp directory and clean it in some period of time from not necessary files
When your start work with real "huge project" that include many e.g. .csproj projects your can create Runtime directory to storage all your executable files and files created during build of application
I hope that this description will be helpful.

What is a PDB file?

What is a PDB file and how can I exclude it from the release folder when I rebuild my solution?
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".
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.
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.
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

Categories

Resources