Reputation: 5724
I'm trying to configure a Team Build in VS/TFS2010. I want the MSBuild arguments to include the following:
/p:Changeset=BuildDetail.SourceGetVersion
I want MSBuild to expand "BuildDetail.SourceGetVersion". I know how to do this by editing the xaml, but I'm hoping there's a way to get it to work without needing to that. Any ideas?
Upvotes: 2
Views: 2025
Reputation: 9705
I know you asked about TFS 2010.
But since TFS 2013 there is a very simple way of doing this!
Just use TF_BUILD_SOURCEGETVERSION var in your MsBuild, it's passed from TFS Build.
See TF_BUILD environment variables for reference
Upvotes: 1
Reputation: 9938
You need to execute the TFS task
<UsingTask
TaskName="Microsoft.TeamFoundation.Build.Tasks.GetBuildProperties"
AssemblyFile="C:\Program Files\Microsoft Team Foundation Server 2010
\Tools\Microsoft.TeamFoundation.Build.ProcessComponents.dll"
/>
<Target Name="MyTarget">
<GetBuildProperties
TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
BuildUri="$(BuildUri)">
<Output TaskParameter="BuildNumber" PropertyName="BuildNumber" />
<Output TaskParameter="SourceGetVersion" PropertyName="SourceGetVersion" />
</GetBuildProperties>
</Target>
I'd use properties to compute the path to the assembly, since it may vary, and since on a developer machine it will be under the Visual Studio install (in PrivateAssemblies I think).
Since the property comes dynamically from a target execution, anything you do based on this property will have to be calculated dynamically as well. Forming globally static properties based on $(SourceGetVersion) won't work. Of course, you could calculate it and then use the MSBuild task to run the real build, but that becomes tedious since you need to pass other properties along. If you want something better, you'll end up where I did, rewriting the Xaml to pass it into the MSBuild Action.
Upvotes: 6