Hosting your own Source & Symbol Server

If you are using NuGet to add 3rd party components in your project, you should also use to get debug info and source code for those components. If you are not familiar with, 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 Also here’s an MSDN article with more technical details

I am hosting my own NuGet server and I want to host my own Source and Symbol server as well. I can’t use because the code is proprietary and even though I could get a non-public account on 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,

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 ""

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!

This Post Has 2 Comments

  1. Hi Johan Olsson, I am trying to the application which you created, to change the source path in my pdb, such that it points to server path.. But i am not able to use it. Please provide me the steps what i have to do to make your application work in my environment.Please do let me know if you want any more information.

    Thanks in advance..


Leave a Reply

Close Menu