Question

Say I have a version number 1.5.* that is compiled as 1.5.4735.28467.

What is the formula for getting 4735 and 28467?

Was it helpful?

Solution

Please note: there are alternative tools/rules/schemes/macros/add-ins/etc to control versioning in a different manner; if used they obviously obliterate the following.

However, this is how a "*" version is calculated to .build.revision in a vanilla Visual Studio / .NET build process:

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.

See Coding Horror: Determining Build Date the hard way and MSDN: AssemblyVersionAttribute. This default expansion behavior is documented in the AssemblyVersionAttribute class (BCL!) and not special VS compiler behavior (see Daniel's comment) and not exclusively compiler behavior.


Here is one implementation of the formula (as extracted from Daniel's comment):

int Build = DateTime.Today.Subtract(new DateTime(2000, 1, 1)).Days;
int Revision = (int)DateTime.Now.Subtract(DateTime.Today).TotalSeconds / 2; 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top