Jul 1, 2010

MSBuild Properties in TFS 2010

In a TFS 2010 build running on the default workflow template, we can access some of the build properties at runtime within an MSBuild project file. Use the GetBuildProperties task in your target to get the initial values of the build number, the build definition name, etc.
Checkout this task in
$(MSBuildExtensionsPath)\Microsoft\VisualStudio\TeamBuild\Microsoft.TeamFoundation.Build.targets to get the complete list of properties that can be accessed.

Note:
Pass this as an MSBuild Argument in your build definition's advanced settings:
TeamBuildRefPath="C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies"
Else, the build might fail with this error:
The "Microsoft.TeamFoundation.Build.Tasks.GetBuildProperties" task could not be loaded from the assembly \PrivateAssemblies\Microsoft.TeamFoundation.Build.ProcessComponents.dll