[Update 30/04/2008] Fixed issue for Build Definition names that contain spaces.
[Update 08/07/2008] Updated for new version of Debugging Tools for Windows; added Troubleshooting chapter.
[Update 05/08/2008] Updated "srcsrv.ini" file contents for new version of Source Server script (does not include cmd.exe anymore).
[Update 20/03/2009] Added troubleshooting part for "Illegal characters in path" error.
[Update 30/03/2009] Updated "Illegal characters in path" patch to also include the srcsrv.dll file (in addition to symsrv.dll).
I've read about symbol servers and source servers before (in John Robbins' excellent Debugging Microsoft .NET 2.0 Applications book, for example, and also due to the recent news that Visual Studio 2008 will support source-code debugging of the .NET Framework Libraries), but never really got around to trying them out since they seemed pretty complex to set up. However, I've recently set up a source server on a Team Foundation build server (twice!), and my eyes have now gone wide open: anybody who references assemblies built by those TFS build servers can now seamlessly debug them.
When an assembly is "source server-enabled", the pdb file will contain the full path and the exact version of the file in source control that was used to build that assembly. If the debugger then enters a method, Visual Studio automatically downloads that correct file, places it in a local cache, and opens it for debugging. This is super sweet!
Now the hard work is already done and available in the Debugging Tools for Windows, but there are some extra steps to take if you want to integrate this in a real Team Build (i.e. on the TFS build server instead of on a local machine) and it also lacks some additional information to get everything working. So I put together a full document that covers all aspects of setting up a source server, modifying the Team Build script, configuring the project files, and finally configuring the development machines.
The full document (PDF) can be downloaded here, and you can read the one-page summary that briefly covers the required steps below. I cannot recommend setting up a source server enough, it's free and takes less than an hour if you simply follow the procedure, and the advantages are - hopefully - obvious.
Setting up Source Server for TFS Builds.pdf (0,98 MB)
Note that this procedure works for both TFS 2005 as TFS 2008, and both VS 2005 as VS 2008.
Installing Source Server on the Build Server
- Install the Debugging Tools for Windows (at least the "Source Server" component)
- Install Perl (e.g. ActivePerl)
- In the tfsindex.cmd file in the Debugging Tools for Windows directory, change the last line to
@call "%~dp0SSIndex.cmd" -SYSTEM=TFS -SYMBOLS=%1 %*
Enabling Source Server in the Team Build Script
- In the srcsrv.ini file in that directory, set MYSERVER to the exact URL of your Team Foundation Server (Application Tier)
- Add the full path to TF.exe (usually "C:\Program Files\Microsoft Visual Studio 8\Common7\IDE" for VS 2005 or "C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE" for VS 2008) to the system's Path environment variable
- Restart the "Team Build Service" (for TFS 2005) or "Visual Studio Team Foundation Build" (for TFS 2008) Windows service
- Add a new target to TFSBuild.proj to be run on "AfterCompile" that calls tfsindex.cmd:
<Target Name="RunSourceServerIndexing">Configuring the Project Files
<Exec Command=""C:\Program Files\Debugging Tools for Windows (x86)\srcsrv\tfsindex.cmd" "$(BinariesRoot)""
Configuring the Development Machines
- Set the Debug Info in Project Properties / Build / Advanced to "full" (Debug configuration) or "pdb-only" (Release configuration)
- In Visual Studio / Tools / Options / Debugging / General: check the "Enable source server support" checkbox
- Create a new text file named srcsrv.ini in the Visual Studio directory (usually "C:\Program Files\Microsoft Visual Studio 8\Common7\IDE" for VS 2005 or "C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE" for VS 2008) that contains the exact following text: