views:

309

answers:

2

I am attempting to get the latest changeset version in a TFS MSBuild. I have tried a number of solutions, and have referenced http://stackoverflow.com/questions/1630823/tfs-and-msbuild-version-number-with-last-changeset without the desired result. Any other ideas?

  1. Some blog entries/examples suggest using 'tf changeset /latest /i msbuild', however I cannot find documentation on how to get the desired value into a property inside an MSBuild xml file.

  2. Other examples suggest using the msbuild extension pack, however the documentation is not complete, and the 'changesets' property below appears to be empty.

Refer to: http://social.msdn.microsoft.com/Forums/en/msbuild/thread/3fd46d76-2544-4818-b504-0fa2fc1e5c6a

    <MSBuild.ExtensionPack.Tfs.TeamBuild TaskAction="RelatedChangesets" TeamFoundationServerUrl="$(TeamFoundationServerUrl)" TeamProject="$(TeamProject)" BuildUri="$(BuildUri)" BuildDefinitionName="$(BuildDefinitionName)">

   <Output ItemName="changesets" TaskParameter="RelatedItems"/>
  </MSBuild.ExtensionPack.Tfs.TeamBuild>
  <Message Text="ID = %(Changesets.Identity), Checked In By = %(Changesets.CheckedInBy), URI = %(Changesets.ChangesetUri), Comment = %(Changesets.Comment)"/>

This Produces: Task "Message" "ID = , Checked In By = , URI = , Comment = "

It has also been suggested I use the following after the teambuild task above, but again since the 'changesets' property is empty, I get an error:

Refer to: http://social.msdn.microsoft.com/Forums/en/msbuild/thread/9ac51ffe-137f-4d55-87e1-6fbbc401aab1

    <!-- Get the last item -->
  <MSBuild.ExtensionPack.Framework.MsBuildHelper TaskAction="GetLastItem" InputItems1="@(changesets)">
   <Output TaskParameter="OutputItems" ItemName="LastItem"/>
  </MSBuild.ExtensionPack.Framework.MsBuildHelper>
  <Message Text="Last Item: %(LastItem.Identity)"/>

edit: correct code and add reference links

A: 

If you were using Team Build 2010, you could use BuildDetail.SourceGetVersion. This simply give you changeset number.

afsharm
Thanks, yes we hope to upgrade to 2010 soon, but of course that is not an option at the moment.
davewilliams459