AssemblyInfo 内部版本号未更新

AssemblyInfo build number not updated

我在AssemblyInfo.cs中有以下代码:

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

我试图确保每次 build/rebuild 我的项目时 Build Number 都会改变。但是,在那种情况下它不会。如果我在不同的日子构建它,只有 Revision 会改变。

我错过了什么?

尝试注释掉 [程序集:AssemblyFileVersion(“1.0.0.0”)] 只留下 [程序集:AssemblyVersion("1.0.*")]

您需要注释掉

// 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")]

MSDN 说:

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.

是文件版本没有改变吗?

第三个数字(共 4 个)是自 2000 年以来的天数。这不会随着每次构建而改变,只会随着时间的流逝而改变。

将其更改为:

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

只需评论一下:

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

如果您需要更改 AssemblyFileVersion,则必须手动进行..

或者,您可以使用 T4 模板机制,如所述HERE