If you are using NuGet to add 3rd party components in your project, you should also use SymbolSource.org to get debug info and source code for those components. If you are not familiar with SymbolSource.org, it is a service that hosts debug information (.pdb-files) and source code for open source projects. When you debug your project in VisualStudio and step into 3rd party code, Visual Studio automatically downloads the source and you can debug it like it was your own code. Cameron Skinner has written an excellent blog post that explains a Symbol Server works http://blogs.msdn.com/b/camerons/archive/2011/04/01/debugging-series-symbol-server.aspx Also here’s an MSDN article with more technical details http://msdn.microsoft.com/en-us/library/ms680693.aspx
I am hosting my own NuGet server and I want to host my own Source and Symbol server as well. I can’t use SymbolSource.org because the code is proprietary and even though I could get a non-public account on SymbolSource.org the customer I am working with has a strict security policy of not letting the code leave the company network. So, I must host it myself, but how?
The Source Server
Setting up the source server was simple. Just create a file share, create a folder with the version number as name and put your source code there. So if I have a C# file named MySourceCode.cs in MyProject, the path to the source code will be myServerMySourceShareversion1.0MyProjectMySourceCode.cs
The Symbol Server
When you build a .Net assembly in VisualStudio you get one dll file and one pdb file. The pdb file contains debug information and references to the source code that makes up the assembly. There is only one problem with this. The references to the source files are absolute paths. If I have the source code in a file C:WorkTheCustomerMyProjectMySourceCode.cs, the pdb file will contain that absolute path.
Thus we must modify the pdb file to contain the path to the source server instead. This is a process call ‘Source Indexing’, and here’s an MSDN article about it, http://msdn.microsoft.com/en-us/library/ms680641(v=VS.85).aspx
The source indexing tools in ‘Debugging Tools for Windows’ is a collections of executables and perl scripts, but none of the srcipts do exactly what I want. What I want to do is replacing ‘C:WorkTheCustomerMyProjectMySourceCode.cs’ with ‘myServerMySourceShareversion1.0MyProjectMySourceCode.cs’. I am not proficient in Perl, so I wrote a small console program in C# that takes the replacement paths and modifies the pdb . Please see attachment.
Now we are ready to publish the pdb. Create a second file share ‘myServerMySymbolShare’ and publish the modified pdb there by running symstore.exe (also from ‘Debugging Tools for Windows’).
symstore.exe add /f myProject.pdb /s myServerMySymbolShare /t "MyProject" /v "220.127.116.11"
Setting Up VisualStudio
Finally we have to tell VisualStudio to search for symbols and source on our new shares.
a. In VisualStudio select “Debug->Options and Settings”
b. Select ‘General’ category
c. Uncheck “Enable Just My Code”
d. Check “Enable source server support”
e. Select ‘Symbols’ category
f. Add a new path by clicking the folder icon in upper right corner. Set name to: “myServerMySourceShare”
g. Add another path. Set name to: “myServerMySymbolShare”
That’s it! When you debug ‘MyProject’, you can step in to the code and VisualStudio will automatically download the source code and display it. Sweet!