Passing TFS Build properties to MSBuild using TFS 2010 or later

TFS does not pass the build number and binaries directory as variables to MSBuild by default. If you're using the TFS MSBuild scripts, you'll need to follow the manual steps described below to avoid builds failing. 

You must also follow the configuration steps described in Using the DLM Automation TFS MSBuild scripts.

Passing TFS 2015 and 2013 build properties to MSBuild

  1. Open your build definition for editing and click Process.
  2. In the Build process parameters areas, expand the Advanced heading and click in the MSBuild Arguments field.
  3. Paste the following:

    /p:tfs_buildNumber="$(TF_BUILD_BUILDNUMBER)" /p:tfs_binariesDirectory="$(TF_BUILD_BINARIESDIRECTORY)"
  4. Press Ctrl+S to save the build definition.

Passing TFS 2012 and 2010 build properties to MSBuild

Edit the build process XAML file used in your build:

  1. To find the path for your build process file in Source Control, open your build definition for editing and click Process:

    The source control path for the file is displayed.
  2. Open this file in a text editor.
  3. Find any occurrences of the element:

    "[String.Format("/p:SkipInvalidConfigurations=true {0}", MSBuildArguments)]"
  4. Replace every occurrence with:

    "[String.Format("/p:SkipInvalidConfigurations=true /p:tfs_binariesDirectory=""{2}"" /p:tfs_buildNumber={1} {0}", MSBuildArguments, BuildDetail.BuildNumber, BinariesDirectory)]"
  5. Commit the edited XAML file to source control.

Didn't find what you were looking for?