Customize Team Build 2010 – Part 12: How to debug my custom activities
In the series the following parts have been published
Part 1: Introduction 
Part 2: Add arguments and variables 
Part 3: Use more complex arguments 
Part 4: Create your own activity 
Part 5: Increase AssemblyVersion 
Part 6: Use custom type for an argument 
Part 7: How is the custom assembly found 
Part 8: Send information to the build log 
Part 9: Impersonate activities (run under other credentials) 
Part 10: Include Version Number in the Build Number 
Part 11: Speed up opening my build process template 
Part 12: How to debug my custom activities 
Part 13: Get control over the Build Output 
Part 14: Execute a PowerShell script 
Part 15: Fail a build based on the exit code of a console application 
 
 
 
Developers are “spoilt” persons who expect to be able to have easy debugging experiences for every technique they work with. So they also expect it when developing custom activities for the build process template. This post describes how you can debug your custom activities without having to develop on the build server itself.
Remote debugging prerequisites
The prerequisite for these steps are to install the Microsoft Visual Studio Remote Debugging Monitor. You can find information how to install this at http://msdn.microsoft.com/en-us/library/bt727f1t.aspx. I chose for the option to run the remote debugger on the build server from a file share.
Debugging symbols prerequisites
To be able to start the debugging, you need to have the pdb files on the buildserver together with the assembly. The pdb must have been build with Full Debug Info.
Steps
In my setup I have a development machine and a build server. To setup the remote debugging, I performed the following steps
Locate on your development machine the folder C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Remote Debugger 
Create a share for the Remote Debugger folder. Make sure that the share (and the folder) has the correct permissions so the user on the build server has access to the share. 
On the build server go to the shared “Remote Debugger” folder 
Start msvsmon.exe which is located in the folder that represents the platform of the build server. This will open a winform application like   
Go back to your development machine and open the BuildProcess solution. 
Start the Attach to process command (Ctrl+Alt+P) 
Type in the Qualifier the name of the build server. In my case the user account that has started the msvsmon is another user then the user on my development machine. In that case you have to type the qualifier in the format that is shown in the Remote Debugging Monitor (in my case LOCAL\Administrator@TFSLAB) and confirm it by pressing <Enter>  
Since the build service is running with other credentials, check the option “Show processes from all users”. 
Now the Attach to process dialog shows the TFSBuildServiceHost process  
Set the breakpoint in the activity you want to debug and kick of a build. 
Be aware that when you attach to the TFSBuildServiceHost that you debug every single build that is run by this windows service, so make sure you don’t debug the build server that is in production!
You can download the full solution at BuildProcess.zip. It will include the sources of every part and will continue to evolve.