Within an MSBuild file I would like to extract the changeset
number from the output of the following command into a $(parameter)
value;
<Exec Command="c:\path\tf.exe changeset /latest /i" />
In my build script I can see the Changeset number in the first line of the result:
Changeset: 7539
User: John Doe Date: 23 September 2015 17:03:19Comment:
some check-in commentItems: [[List of items here]]
Work Items: [[List of linked work items here]]
I feel like I am very close and want the simplest solution. I can use MSBuild.ExtensionPack or the MSBuild.Community tasks if there is a better option.
To only get the changeset number, please try the following steps: (code is quoted from this link):
<UsingTask TaskFactory="PowershellTaskFactory" TaskName="Changeset" AssemblyFile="C:\Program Files\MSBuild\ExtensionPack\4.0\MSBuild.ExtensionPack.TaskFactory.PowerShell.dll">
<ParameterGroup>
<changeset Output="true" />
</ParameterGroup>
<Task>
<![CDATA[
$tf = & "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\tf.exe" history . /r /noprompt /stopafter:1 /version:W
$changeset=$tf[2].Split(" ")[0]
]]>
</Task>
</UsingTask>
<Target Name="TestBuild">
<Changeset>
<Output TaskParameter="changeset" PropertyName="changeset" />
</Changeset>
<Message Importance="High" Text="Changeset:++++++ ::::: $(changeset)" />
</Target>