Search This Blog

Monday, March 8, 2010

Simple build versioning in VS2008

Visual Studio 2008 provides a simple build versioning system already built in.

You only need to edit the "AssemblyInfo.cs" file (in the "properties" section of a project) of a project/assembly and reset the entry:

[assembly: AssemblyVersion("1.0.0.0")]

to

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

It even describes how to do it in the comment section of the file.

Then you can reference the build version with calls to the assembly object thru reflection like this:

System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString()

It'll automatically update the build number after each new build. The updated numbers represent some sort of increment from some date in the past (1/1/2000? See the MSDN article for more details). For our purposes we just needed an incrementing number to show the latest version, so this works fine as a quick fix.

No comments: