A point of interest that has arisen lately is how to automate the version number so that it increments per build without someone having to manually check out code, edit the number and check it back in.
Technically, Visual Studio doesn’t give you the option to increment the version numbers automatically. So, there are a few opinions currently out there on how to do this.
Here’s a post from StackOverflow.com, where this user’s question basically hits it dead on: http://stackoverflow.com/questions/826777/how-to-have-an-auto-incrementing-version-number-visual-studio
user esac asks:
I want to store a set of integers that get auto incremented at build time:
int MajorVersion = 0; int MinorVersion = 1; int Revision = 92;
When I compile, it would auto-increment
Revision. When I build the setup project, it would increment
MinorVersion (I’m OK with doing this manually).
MajorVersion would only be incremented manually.
Then I could display a version number in menu Help/About to the user as:
How can this be achieved?
The Answer chosen was from was from Noel Kennedy about using a wildcard place holder which I’d seen a few times browsing:
If you add an AssemblyInfo class to your project and amend the AssemblyVersion attribute to end with an asterisk, for example:
Visual studio will increment the final number for you according to these rules (thanks galets, I had that completely wrong!)
To reference this version in code, so you can display it to the user, you use reflection. For example,
string version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
Using this method the build and revision numbers are determined as follows:
Build Number is based on(0.0.*.0): Number of days since January 1st, 2000.
Revision Component is based on(0.0.0.*): number of seconds since midnight divided by 2. At 1am this = 1800
The rules referred to in the Answerer’s post are located http://msdn.microsoft.com/en-us/library/system.reflection.assemblyversionattribute.aspx, which is a link for AssemblyVersionAttribute Class on MSDN