Building in Parallel Across Multiple Build Agents with TFS 2010
One of our developers, Patrick Carnahan, has put together a customized build process template that parallelizes a build by platform/configuration. That is, if you use it to build multiple platforms (e.g. “x86” and “x64”) and/or configurations (e.g. “Debug” and “Release”), it will distribute the build of each platform/configuration to a separate Build Agent.
You can download the template from the MSDN Code Gallery: ParallelTemplate.xaml
Once you’ve downloaded the template, you’ll need to add it to your version control repository before you can use it with your build definitions. Just follow these steps to get started:
Open Visual Studio 2010 and connect to your Team Project Collection
Open Source Control Explorer and navigate to the location of your build process templates (e.g. $/Project/BuildProcessTemplates).
Copy the ParallelTemplate.xaml file to the folder on your local disk that this version control folder is mapped to. In Source Control Explorer, you’ll see a link to this folder labeled Local Path. Clicking the link will open Windows Explorer on that folder.
Right click on an empty area of the contents pane and select Add Items to Folder…
The Add To Source Control dialog will open. It will automatically hide any files that are already checked in, so you should only see the ParallelTemplate.xaml file that you just copied to this folder.
Click Next and you’ll be asked to confirm the operation – click Finish to pend the add.
Right click on the file and select Check In Pending Changes… Enter an appropriate check-in comment and commit the add.
Next, create a new Build Definition, or edit an existing one. Select the Process page of the Build Definition Editor and click the Show Details button to see the details of the currently selected build process template. You’ll need to click New… to select the XAML file you just checked into version control.
Click the Select an existing XAML file radio button and click Browse… to browse for the ParallelTemplate.xaml file you just checked in.
The build process parameters for the Parallel Template are the same as the ones for the Default Template, so no other changes are required to your existing build definition.
Things to keep in mind when using this build process template:
- Builds are parallelized by platform/configuration so, if you’re only building one platform/configuration, your build won’t be distributed across multiple Build Agents.
- You’ll need more than one Build Agent available for this build process to parallelize your build. Keep in mind that you can configure multiple Build Agents on a single physical machine – appropriate if the machine has multiple processor cores. Note that you may want to configure each Build Agent to use a working directory on a separate physical disk, if multiple local disks are available.