Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I insert the latest TFS changeset number into an aspx page?

When we were using SVN, we'd always print at the footer of our pages: "Revision XXXX". I've been looking, but I can't figure out how to do the same thing with TFS. Can anyone offer some pointers?

In case this matters: we're using ASP.NET MVC. I'm guessing it doesn't matter, however.

like image 313
Esteban Araya Avatar asked Nov 18 '10 17:11

Esteban Araya


2 Answers

You can use the default version system for assemblies to track revisions number without adding anything in TFS.

If you use the Major.Minor.* format in your AssemblyInfo's AssemblyVersion attribute (e.g. [assembly: AssemblyVersion("1.0.*")]) it will generate a version according to the following format:

Major.Minor.Build.Revision

where

  • Major = Your value
  • Minor = Your value
  • Build = Number of days since 2000/01/01
  • Revision = (Number of seconds since midnight on the day specified in Build) / 2

This will give you an always increasing number which gives you precise information on build date and time.

To use these values in your code, you can simply recover the version using Assembly.GetExecutingAssembly().GetName().Version.

like image 165
dee-see Avatar answered Oct 22 '22 23:10

dee-see


You can update version number of projects in AssemblyInfo.cs using assembly versioning tools/techniques like this. Version number of an assembly can be updated based on TFS changeset number. Version number then can be displayed in application.

like image 23
Afshar Mohebi Avatar answered Oct 22 '22 22:10

Afshar Mohebi