Wednesday, August 17, 2011

TFS Build Service Tips

My organization is hosting TFS for multiple customers.  To keep everyone isolated (and happy) we have multiple Team Project Collections, but the downside is we need to setup a separate Build Controller for each Site Collection (see MSDN article for more pros/cons).  TFS 2010 changed to only allow a 1 to 1 pairing between a TFS Collection and a Build Controller.

 

Setting up a Build Controller is fairly straightforward.  Here are some tips that I have found helpful:

1.       Create an AD account for the service.  It’s easier to grant permissions to output folders and network shares using named users/groups.  Do this before running the Build Controller wizard – it will add the necessary groups and permissions for you.

2.       Run the TFS Setup and only select “Build Controller” for the install.

3.       Use the Build Controller wizard at the end of the install to connect to your Team Project Collection.

4.       If Visual Studio is not installed on the Build Controller, copy the MS Build targets from a developer machine to:
  C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0

5.       Add a Build project to copy our compiled output to an integration server (see example file below)

 

<?xml version="1.0" encoding="utf-8"?>

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <ItemGroup>

    <MySourceFiles Include="$(OutDir)_PublishedWebsites\<Your Web Project>\**\*.*" />

  </ItemGroup>

  <Target Name="CopyFiles">

    <Copy

        SourceFiles="@(MySourceFiles)"

        DestinationFolder="\\<Network Share>"

        />

  </Target>

</Project>