user2254686
user2254686

Reputation: 95

Version Number with TFS in MVC

Quick question, is it possible to retrieve a Continuous Integration number / version number from TFS and use it as part of a site after building.

e.g. The latest version of an MVC project from the TFS is used as part of a demo. I would like to use the version number from the TFS inside the MVC application.

The version number displayed on-screen (in the footer perhaps).

The reason I would like to do this is to display - to the viewers of the demo - exactly which version they are viewing and how much has changed since the last version they saw.

I realize this is probably a silly question and I'm not positive that what I'm trying to do is practical / feasible.

P.S. I am at the moment using

[assembly: AssemblyVersion("1.0.*")]

from AssemblyInfo.cs and converting this to a readable date (e.g. 03/01/2014 17:28) to outline the version time of the project and displaying this on the Home page of my MVC project. This works fine.

Upvotes: 2

Views: 726

Answers (1)

Nicholas Carey
Nicholas Carey

Reputation: 74177

Usually you configure your CI service so that the build

  • increments the version/build number as appropriate
  • uses that number to construct the label used to label the source tree in source control
  • extracts the contents of the source tree into a build directory
  • scans the source tree for AssemblyInfo.cs fileses, changing their AssemblyVersion attributes to properly reflect the generated version/build number

Et voila! All your assemblies are properly marked with the correct version number.

At least, that's the way we've always done it. The specifics of this, of course, are entirely dependent on the specifics of

  • Your source control system
  • Your CI system
  • Your build system.

It's pretty straightforward with nAnt and CruiseControl.Net and most mainline source control systems. I imagine doing the same with other CI servers isn't much more difficult. If you're using more oddball source control, like Serena Dimensions, ClearCase or TFS, it might be a little more difficult.

Upvotes: 1

Related Questions