Skip to content

Instantly share code, notes, and snippets.

@JamesWoolfenden
Created November 14, 2013 16:41
Show Gist options
  • Save JamesWoolfenden/7470026 to your computer and use it in GitHub Desktop.
Save JamesWoolfenden/7470026 to your computer and use it in GitHub Desktop.
How to get the TFS changeset for a build.
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<AssemblyFile>.\packages\MSBuild.Extension.Pack.1.3.0\tools\net40\MSBuild.ExtensionPack.TaskFactory.PowerShell.dll</AssemblyFile>
</PropertyGroup>
<UsingTask TaskFactory="PowershellTaskFactory" TaskName="Changeset" AssemblyFile="$(AssemblyFile)">
<ParameterGroup>
<changeset Output="true" />
</ParameterGroup>
<Task>
<![CDATA[
$tf = & "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\tf.exe" history . /r /noprompt /stopafter:1 /version:W
$changeset=$tf[2].Split(" ")[0]
]]>
</Task>
</UsingTask>
<Target Name="Build">
<Changeset>
<Output TaskParameter="changeset" PropertyName="changeset" />
</Changeset>
<Message Importance="High" Text="Changeset $(changeset)" />
</Target>
</Project>
@JamesWoolfenden
Copy link
Author

I was trying to get TFS and teambuild to use the TFS changeset as its versioning scheme, well the hack above gets you the changeset. But you cant set your build number to reflect it (In teambuild) so it not much cop is it? (I mean we knew that already but....)
Another reason to use Teamcity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment