June 2008
Sun Mon Tue Wed Thu Fri Sat
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30          
Search

 
Catagories
Archives
Recent Entries
Links
RSS
build revision numbering scheme
Catagory: programming · This Entry · Comment(0) · eMail entry · Google
March 22, 2004 12:45 PM

programming

So, you know the format of the version string goes like: major. minor. build. revision.

and you manage that in the AssemblyInfo file... <Assembly: AssemblyVersion("1.0.*")>

But what are those auto-generated values for build and revision?


Here's the deal. When specifying a version, you have to at least specify major. If you specify major and minor, you can specify an asterisk (*) for build. This will cause build to be equal to the number of days since January 1, 2000 local time, and for revision to be equal to the number of seconds since midnight local time, divided by 2.

If you specify major, minor, and build, you can specify an asterisk for revision. This will cause revision to be equal to the number of seconds since midnight local time, divided by 2.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemReflectionAssemblyVersionAttributeClassctorTopic.asp

valid version strings are:

X
X.X
X.X.*
X.X.X
X.X.X.*
X.X.X.X

where X is an unsigned short constant, from 0 to 65534. (Now you see why they couldn't just put the number of seconds from midnight).


But, you can also create custom formats... here's an example of a possible alternate :

<%
var now:DateTime = DateTime.Now;
var build:short = (short)(now.Year);
var revision:short = (short)(now.Month*1000 + now.Day*10 + now.Hour*10/24);
%>

[assembly: System.Reflection.AssemblyVersion(
"<%= major %>.<%= minor %>.<%= build %>.<%= revision %>"
)]


but if that doesn't suite your needs there's also AssemblyInformationalVersionAttribute, as a place to store build revision data. which you can change without breaking strong

The informational version number is really just a string, displayed by the shell and administrative tools

using System.Reflection;
[assembly:AssemblyInformationalVersionAttribute("Debug build!")]

Keep in mind, the CSC.exe and AL.exe tools support the ability to automatically increment the assembly version number with each build. But, changing the assembly version number will break any assemblies that reference this assembly.

Finally there's also AssemblyFileVersion. So there are three version numbers associated with an assembly: The AssemblyFileVersion, the AssemblyInformationalVersionAttribute, and the AssemblyVersion. The CLR only cares about the last one and that the other two are informational only, ignored by the CLR.

You can increment the file build number using this :

public string Version()
{
string fileLocation;
fileLocation = Assembly.GetExecutingAssembly().Location;
return "ver: " + FileVersionInfo.GetVersionInfo(fileLocation).FileVersion;
}





Comments

Post a comment
Name:


Email Address:


URL:


Comments: