AssemblyInfo build number not updated

5k Views Asked by At

I have the following code in AssemblyInfo.cs:

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

I'm trying to make sure the Build Number changes each time I build/rebuild my project. But, in that case it doesn't. Only the Revision changes if I build it on different days.

What am I missing?

4

There are 4 best solutions below

5
Karl Gjertsen On BEST ANSWER

Is is the File Version that is not changing?

The third number (out of 4) is the number of days since 2000. This will not change with each build, only with each passing day.

Change it to be:

[assembly: AssemblyVersion("1.0.*")]
1
user2667069 On

Try commenting out [assembly: AssemblyFileVersion("1.0.0.0")] and leave only [assembly: AssemblyVersion("1.0.*")]

0
Rahul Tripathi On

You need to comment out the

// Version information for an assembly consists of the following four values:
//
//      Major Version
//      Minor Version 
//      Build Number
//      Revision
//
// You can specify all the values or you can default the Build and Revision Numbers 
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.*")]
//[assembly: AssemblyFileVersion("1.0.0.0")]

The MSDN says:

You can specify all the values or you can accept the default build number, revision number, or both by using an asterisk (). For example, [assembly:AssemblyVersion("2.3.25.1")] indicates 2 as the major version, 3 as the minor version, 25 as the build number, and 1 as the revision number. A version number such as [assembly:AssemblyVersion("1.2.")] specifies 1 as the major version, 2 as the minor version, and accepts the default build and revision numbers. A version number such as [assembly:AssemblyVersion("1.2.15.*")] specifies 1 as the major version, 2 as the minor version, 15 as the build number, and accepts the default revision number. The default build number increments daily. The default revision number is the number of seconds since midnight local time (without taking into account time zone adjustments for daylight saving time), divided by 2.

0
Amel On

Just comment this:

[assembly: AssemblyVersion("1.0.*")]    
//[assembly: AssemblyFileVersion("1.0.0.0")] 

If you need to change AssemblyFileVersion, you will have to do it manually..

Or, you can use T4 templating mechanism, as described HERE