Friday, May 6, 2011

Automatically updating a file with Revision from TFS?

I'm quite new to TFS (actually I only use it because I have some projects on CodePlex and did not want to go through svnbridge), and I'm looking for something equivalent to the $Revision$ parameter in SVN.

Essentially on checkout, I want to update a file to contain the newest Revision number, to be displayed as Version number (just like at the bottom of SO).

Is there anything already built-in in msbuild of .net 3.5 SP1, or any official/standard msbuild task, or even something equivalent of just dropping $Revision$ and having the TFS client do the magic on checkout?

From stackoverflow
  • Keyword expansion is not currently supported in TFS. This often takes people by suprise. Below are a couple of blog posts on the topic, you will also find a link there to take you to the Microsoft site if you want to vote for the feature. I know that it is something that the Team get asked for from time to time - but they have yet to come across anyone that actually needs keyword expansion anymore, just a lot of folks are kinda just used to it.

    Anyway - have a read and see what you think.

    Michael Stum : Thanks. Well, I agree on the questionable usage scenario of many keywords, but Revision (or any other way to get the Changeset Number) is one that is really useful when doing regular builds.
  • Michael,

    From within a Team Build you can access the changeset number being built using the $(SourceGetVersion) variable. You could override the AfterGet or BeforeCompile extensibility targets and push the contents of this variable into whatever files you need it in.

    Regards,

    William D. Bartholomew (Team System MVP)

0 comments:

Post a Comment