One of the lesser known features of the Team Build 2008 service is that it can be run in an “interactive” mode which allows it to interact with the desktop. This is essential for running things like automated UI tests.

Running TFSBuildService.exe in interactive mode from a command prompt

To start an Interactive Team Build agent you have to logon to your build server and run this from a command prompt as your build user (e.g. DOMAINTFSBuild):

C :P rogram FilesMicrosoft Visual Studio 9.0Common7IDEPrivateAssembliesTFSBuildService.exe

This starts an instance of the Team Build service listening on port 9192 by default. You can change the port number by following the MSDN How to: Configure an Interactive Port for Team Foundation Build.

There is a caveat with this, in that you have to remain logged into the desktop for the build to work. The best thing to do here is just lock the workstation, or disconnect the remote desktop session. One of the problems that you will have is when the build server gets rebooted, or somebody logs the build user out and kills the TFSBuildService.exe process. You’ll have to log back into the server and start the process again.

You could also logon as a different user and run the command prompt as the build user by using the runas command.

Adding the Build Agent to TFS

TFS2008 build agents are configured on a per-Team Project basis. So for each team project that you want to use the interactive agent, you’ll have to add it.

To add a new build agent:

  1. Open Team Explorer
  2. Right-click on the Builds folder within your Team Project
  3. Select Manage Build Agents..

Team Explorer Builds context menu

On the Manage Build Agents dialog, you may already have an existing non-interactive build agent. Select “New…”

image

Then setup a new Build Agent using port 9192. It’s also a good idea to identify the build agent as a UI-capable agent in the name.

New Build Agent dialog

Now when you Queue a new build, you can select the UI-capable build agent. If you want to change this agent to be the default, you will need to update the <BuildMachine> property in your TFSBuild.proj.

Queue Build dialog showing how to select the UI build agent

That’s all for now. I’m working on a post that shows how to use an Interactive Build Agent to run HP/Mercury Quick Test Professional UI tests using the QuickTest.Application COM object.



One Response to “Running an Interactive Team Build 2008 agent”  

  1. 1 Karl Burdack

    Thats perfect for some tasks we have that utilize directx 10, which refuses to work in a service account.

    I just put this in a batch file:

    “%VS90COMNTOOLS%..\IDE\PrivateAssemblies\TFSBuildService.exe”

    Note that x64 windows has a different program files dir, so Ive used this shell var instead.

    And added the batch file to the startup group in the start menu for the desktop account

Leave a Reply