Passing TFS Build properties to MSBuild using TFS 2010 or later
Published 10 March 2016
TFS doesn't 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 belwo to avoid builds failing.
You must also follow the configuration steps described in Use the TFS MSBuild scripts.
Passing TFS 2015 and 2013 build properties to MSBuild
- Open your build definition for editing and click Process.
- In the Build process parameters areas, expand the Advanced heading and click in the MSBuild Arguments field.
Paste the following:
/p:tfs_buildNumber="$(TF_BUILD_BUILDNUMBER)" /p:tfs_binariesDirectory="$(TF_BUILD_BINARIESDIRECTORY)"
- 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:
- 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. - Open this file in a text editor.
Find any occurrences of the element:
"[String.Format("/p:SkipInvalidConfigurations=true {0}", MSBuildArguments)]"
Replace every occurrence with:
"[String.Format("/p:SkipInvalidConfigurations=true /p:tfs_binariesDirectory=""{2}"" /p:tfs_buildNumber={1} {0}", MSBuildArguments, BuildDetail.BuildNumber, BinariesDirectory)]"
Commit the edited XAML file to source control.