开发者

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" 开发者_StackOverflowItemName="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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜