Customize Team Build 2010 – Part 12: How to debug my custom activities

by Ewald Hofman 1. October 2010 14:19

In the series the following parts have been published

  1. Part 1: Introduction
  2. Part 2: Add arguments and variables
  3. Part 3: Use more complex arguments
  4. Part 4: Create your own activity
  5. Part 5: Increase AssemblyVersion
  6. Part 6: Use custom type for an argument
  7. Part 7: How is the custom assembly found
  8. Part 8: Send information to the build log
  9. Part 9: Impersonate activities (run under other credentials)
  10. Part 10: Include Version Number in the Build Number
  11. Part 11: Speed up opening my build process template
  12. Part 12: How to debug my custom activities
  13. Part 13: Get control over the Build Output
  14. Part 14: Execute a PowerShell script
  15. Part 15: Fail a build based on the exit code of a console application
  16. Part 16: Specify the relative reference path 

 

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

  1. Locate on your development machine the folder C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Remote Debugger
  2. 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.
  3. On the build server go to the shared “Remote Debugger” folder
  4. Start msvsmon.exe which is located in the folder that represents the platform of the build server. This will open a winform application like

    image 
  5. Go back to your development machine and open the BuildProcess solution.
  6. Start the Attach to process command (Ctrl+Alt+P)
  7. 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>

    image
  8. Since the build service is running with other credentials, check the option “Show processes from all users”.
  9. Now the Attach to process dialog shows the TFSBuildServiceHost process

    image
  10. 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.

Tags:

Team Build | VSTS 2010

Comments

10/7/2010 7:34:24 AM #

Sid Forcier

Thanks for this post, it's very helpful.

One thing I struggle with regularly regarding Team Build 2010 are propagation issues. It's particularly difficult for me with remote debugging because I can't figure out what gyrations I need to perform to get new PDB file picked up.

I can check it in to source control, stop msvsmon, restart the build service, start msvsmon, reattach my debugger, and it says the symbols aren't loaded for my breakpoints. Other times I can just attach and it works fine.

I've gotten similar quirkiness with modifying custom editors. I found that restarting my IDE will pick up changes to custom editors.

I also have a tendency to want to compile, checkin, and run a build in rapid succession. This often catches the build controller in a restarting state.

I mention all this simply for your consideration as a future post. A discussion of the propagation that goes on in Team Build 2010 would be helpful.

Regardless, thanks for the guide. It's been indispensable!

Sid Forcier United States |

11/9/2010 5:32:37 AM #

trackback

Part 14: Execute a PowerShell script

Part 14: Execute a PowerShell script

Ewald Hofman |

11/10/2010 9:14:30 AM #

pingback

Pingback from blogs.like10.com

TechDays 2010 Presentations « Microsoft Team Foundation Server, SharePoint Server, .NET, and SQL Server

blogs.like10.com |

11/10/2010 11:09:20 AM #

TJO

My Breakpoints do not catch.  Any ideas why?
I noticed by looking into the loaded Modules I see the symbols for  TFSBuildServiceHost.exe  was skipped.

TJO United States |

11/25/2010 5:52:03 AM #

Ewald Hofman

Do you have multiple build agents installed in your TFS environment?

Ewald Hofman Netherlands |

11/30/2010 5:16:41 AM #

Dev

The same issue.
Could you please give a hint how to debug custom activity when multiple agents installed?
Thank you.

Dev United States |

1/1/2011 5:57:11 PM #

Ken

When I'm debugging my build, I can't step into anything that runs in AgentScope (the majority of the build). My breakpoint shows the "The breakpoint will not currently be hit. No executable code is associated with this line." This happens for the built-in build activity types, I haven't tried adding custom types yet. Any thoughts? Thanks

Ken United States |

3/4/2011 7:27:11 AM #

Rainer Schuetz


Thanks for this post, it's very helpful.

I connect to my Buildserver with "Nativ only with no authentication" because I is in a foreign doamin. When i attach to the TFSBuildServiceHost process i get the messages :
"Cannot find or open the PDB file" !!!
I have one Buildcontroller with one Agent on the same machine.
My breakpoint shows the "The breakpoint will not currently be hit.
I have checked in the pdb file in the same location as the Activity DLL.
Also I have copied the two files to my local PrivateAssemblies path.

Any idea ?

Regardless, thanks for the guide. It's been indispensable!

Rainer Schuetz Germany |

5/31/2011 8:22:17 AM #

trackback

Ewald’s posts on TFS Build 2010

Ewald Hofman , an ALM MVP, has written a great series of blog posts on Team Build in Team Foundation Server 2010.  The 2010 release introduces Windows Workflow as the overall orchestrator of the build process.  Ewald walks you through quite a few topics related to this and the other new features.  Check it out! 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 Part 16: Specify the relative reference path Technorati Tags: tfs 2010 , team build , windows workflow

Buck Hodges |

Comments are closed

Powered by BlogEngine.NET 1.6.1.0
Theme by Mads Kristensen


ClusterMap

Statistics

Statistics created at 09 Sep 2009

121 posts
493 comments
329 raters
1958128 visit (1042 per day)
45 users online

Recent comments

Comment RSS