This is the 3rd post in the series of posts about MSBuild. You can read them at:
As you know, TeamBuild builds the latest version by default. At the Target "CoreGet" in the MSBuild script (you can find it at Microsoft.TeamFoundation.Build.targets file), it gets the latest version from source control to the local workspace on the build machine and build the source.
To build a labeled source you have to set a value to the Version property of the Get task in this target.
So, all you need to do is to override the CoreGet target in the TfsBuild.proj file (it's better than override it in the target file because if you do so, this change will affect all builds on the machine...):
1: <Target Name="CoreGet"
2: Condition=" '$(IsDesktopBuild)'!='true' "
3: DependsOnTargets="$(CoreGetDependsOn)" >
5: <!-- Get all the latest sources from the given workspace-->
6: <Get Condition=" '$(SkipGet)'!='true' "
10: Version="$(VersionToBuild)" />
The property in line 10 is the property that do the work...
You can declare the $VersionToBuild variable at the PropertyGroup element or by passing this value from the .rsp file. The easiest way is to declare it at the PropertyGroup element.