Source Server + Subversion = Easy Assembly Debugging

I started using Microsoft Source Server to more easily debug assemblies. Although I'm a strong TDD/BDD advocate, I still find myself in the debugger, especially when working with our own internal, shared libraries.

One of the biggest advantages to using Source Server with Subversion is the ability to quickly and easily retrieve the correct revision of the underlying source code for the assembly being debugged. The majority of the steps are found in MSDN's Bugslayer article. Even though the article is somewhat dated, it still applies, for the most part, to current tools - including VS2008, .NET 3.5 and Subversion.

You will need to the following to get this to work:

  1. Debugging Tools for Windows
  2. ActiveState Perl (required to index the source)

I edited my srcsrv.ini file found in the "Debugging Tools for Windows" subdirectory to contain only the following line:

SOURCESERVER=https://MY_SVN_SERVER.com

Make sure that the source server server directory is in your path. Mine is:

C:Program FilesDebugging Tools for Windows (x64)srcsrv

Also make sure that the Perl bin directory is in your path. After compiling my library I (through our CI server) run the following command:

svnindex.cmd /debug /source="C:Projects[ProjectRoot]" /symbols="C:Projects[ProjectRoot]binDebug"

At this point you should see output from the command informing you that your PDB file(s) have been modified.

Retrieving Source While Debugging

In Visual Studio, create a new project and add the assembly for which you indexed the source code as a project reference. Write some code to call a method in your assembly and set a breakpoint. Run the application and step into (F11) your assembly on the breakpoint.

If you've done everything correctly it will automatically retrieve your source code from Subversion [at the correct revision].

Visual Studio will give you a warning when you attempt to retrieve the source code because it's executing a potentiall unsafe command "cmd /c svn.exe". To suppress this warning I did the following things:

  1. Modified the SVN_EXTRACT_CMD value inside of the svn.pm script and removed "cmd /c". This ensures that svn.exe gets called directly rather than through cmd.exe
  2. Added srcsrv.ini to the C:Program Files (x86)Microsoft Visual Studio 9.0Common7IDE directory which contains the following text:

      [trusted commands]
      svn.exe