What is the required format for assembly versions?

Eric picture Eric · May 3, 2013 · Viewed 7.7k times · Source

The Version class in .NET represents version numbers as consisting of two to four components. AssemblyInfo files specify the following format for the AssemblyVersion and AssemblyFileVersion fileds:

// Version information for an assembly consists of the following four values:
//
//      Major Version
//      Minor Version 
//      Build Number
//      Revision

It is unclear if Build Number and Revision are required here, since they aren't required in the Version class. Are they required? In other words, is this legal?

[assembly: AssemblyVersion("1.0")]
[assembly: AssemblyFileVersion("1.0")]

Or does that need to be represented as the following?

[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

Answer

Eric picture Eric · May 3, 2013

It appears that the AssemblyVersion may be in a variety of forms:

Examples of valid version strings include:
1
1.1
1.1.*
1.1.1
1.1.1.*
1.1.1.1

But AssemblyFileVersion must be of the form major.minor.build.revision:

The file version is normally a string of four numbers, separated by periods, reflecting the major version number, minor version number, build number, and revision number; for example, "1.0.4309.00". If version is not in this format, a compiler warning occurs, and the results displayed in the file properties dialog are unpredictable. Wildcards are not supported.