Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# - Set path to pdb

Is there any way to set a custom path to Program Database files (*.pdb) in C# under Visual Studio 2008? With C++ this was quite simple (Project settings -> Linker -> Debugging -> Generate Program Database File), but for some reason Microsoft seems to have removed (or hidden) it for C#.

I'm aware that the "standard" usage is to have pdb's located in the bin dir alongside the executable, but that directory is becoming quite a mess so I'd really prefer for them to be located in /obj, which is what I always used to do in C++.

Thanks!

like image 380
Metal450 Avatar asked Nov 14 '22 13:11

Metal450


1 Answers

The C# compiler supports this with the /pdb command line option. That option is however not exposed in the IDE's Build tab.

The IDE build process already asks the C# compiler to put the .pdb file in the obj\Debug directory. A copy of it ends up in the bin\Debug by a MSBuild task named CopyFilesToOutputDirectory. This task is configured in Microsoft.Common.targets, a file located in the c:\windows\microsoft.net\framework\v3.5 directory for VS2008. You could technically edit this file and remove the <Copy> element that copies the .pdb. Heed the warning at the top of file, be sure to make a backup copy before you modify it.

I think the basic problem you'll encounter doing this is that this affects all builds of all projects. And that the debugger now no longer can find the .pdb file. That would be the ultimate show-stopper.

like image 152
Hans Passant Avatar answered Dec 21 '22 05:12

Hans Passant