In TFS 2010, when Team Build component is uninstalled from a build machine (also known as build server), the controller and/or agents (also known as build resources) that have been registered against a TFS team project collection will be removed from the collection along with the build service host.

This works great when you don’t want to use the build machine anymore. And it does a good thing by not leaving garbage in your collection database. Should you want to reuse the machine, all you need to do is create a new build controller and/or agents.

But, what if you do want to reuse your current build configuration? Or replacing a decommissioned build machine instead of deleting it? Also don’t forget about the TFS upgrade scenario in which you would need to reinstall the build service hosts to match the upgraded version on the TFS server.

The upgrade steps for build machines are:

  1. Uninstall the current version of Team Build on each build machine.
  2. Upgrade the TFS server to the new version.
  3. Install the new version of Team Build on each build machine and configure it against the newly upgraded TFS server.

When the configuration is done, the build machines should still have their build resources and can start working with the new TFS server.

 

The scenarios I just listed are probably more popular than throwing away a build machine. But those scenarios need the build resources on the TFS server to be around when Team Build is uninstalled from a registered build machine, an option that the current uninstall functionality does not offer. The following steps will tell you the workaround to avoid having your build resources deleted.

1. Unregister first!

Fortunately when you unregister your build service from a team project collection, you have a choice keep or delete the existing build resources. So before uninstalling Team Build, you need to unregister the build service first and select to keep the build resources for latter use. You can unregister your build service from the Build Configuration Administration Console.

unregister

2. Uninstall the current build service

You have a couple of ways to uninstall the build service. I often use the TfsConfig.exe tool:

TfsConfig.exe setup /uninstall:TeamBuild

This command unconfigures the build service host but keeps the binaries intact, so you can reconfigure your build service from a clean state just like a new install.

uninstall

3. Configure the new build service

After installing the new version of Team Build you can reconfigure your build service against the same TFS team project collection and reuse your build controller and/or agents that were previously registered. The Build Service Configuration Wizard gives you a choice to either keep or delete the existing build resources. Choose to keep them if you want to reuse.

configure

On the Review page of this wizard right before the configuration happens, make sure you see the existing build controller and/or agents listed like bellow:

review

 

I have shown a manual way to get around having your build resources deleted when Team Build is uninstalled. If you have a scripted solution to perform the install/uninstall Team Build on a machine, then you might want to update your scripts to unregister the build service host before uninstalling it. 

We’ll improve the experience of this scenario in the next release so this workaround will no longer be needed beyond TFS 2010.