简体   繁体   中英

TFS and MSBuild: how to get latest changeset version

I am attempting to get the latest changeset version in a TFS MSBuild. I have tried a number of solutions, and have referenced 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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM