TFS and msbuild version number with last changeset

Leszek Wachowicz picture Leszek Wachowicz · Oct 27, 2009 · Viewed 14.8k times · Source

I want to create a build number which looks like Major.minor.Date.LastChangeSetInTFS, the problem is how to get last changeset number from the TFS. Is there any property, or something??

Answer

Leszek Wachowicz picture Leszek Wachowicz · Oct 27, 2009

OK finally I've found a solution. Here's a task that will provide you the latest changeset number and create a property to insert it in an Assembly info build number. The main problem was in the missing TfsLibraryLocation property (without it, it should be pointing to libraries in GAC, but it didn't)

<Target Name="GetVersionChangeSet">
<TfsVersion
  TfsLibraryLocation="C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies"      
  LocalPath="$(SolutionRoot)">
  <Output TaskParameter="Changeset" PropertyName="ChangesetNumber"/>
</TfsVersion>
<Message Text="TFS ChangeSetNumber: $(ChangesetNumber)" />