Jusbat
Jusbat

Reputation: 50

How could I auto increment version number with TFS builds without using assemblyinfo?

I have a lot of web application projects. I need a way of having the version number in the footer of each website (visible or hidden, just so I can access the version no.). I want to set up TFS builds so I can automatically publish to a test server on every commit and it will update this version number by itself. I have web deploy set up and working fine, it's just the version number that's the problem. The issue is - the CMS I'm using uses the AssemblyInfo for its own versioning so I can't use this. I need some sort of custom version number that I'm able to auto increment. I've read a lot of example of how to do this using the assembly but can I apply the same principle in another way?

The tools I'm using are - TFS 2010, Visual Studio 2013, ASP.NET web application

Any help is much appreciated, thanks!

Upvotes: 1

Views: 896

Answers (1)

Oscar Foley
Oscar Foley

Reputation: 7025

You can store version in a file (version.xml, version.txt, version.json or similar) and create a version.aspx that reads from file and shows it in the screen. Something like:

version=##version##
changeset=##changeset##

Then, you can add a powershell step in the build that replaces the values from the current build.

    param($version, $ChangeSet)
    (Get-Content version.txt).replace('##version##', $version) | Set-Content version.txt
    (Get-Content version.txt).replace('##ChangeSet##', $ChangeSet) | Set-Content version.txt

Then you invoke the script from a step that passes those two parameters...

Upvotes: 2

Related Questions