CS1607: The version specified for the 'file version' is not in the normal 'major.minor.build.revision' format in .NET

天大地大妈咪最大 提交于 2019-11-30 07:50:20

问题


I am trying to set my AssemblyVersion and AssemblyFileVersion attributes in my project like so:

[assembly: AssemblyVersion("3.0.*")]
[assembly: AssemblyFileVersion("3.0.*")]

but I get this warning:

CS1607: Assembly generation -- The version '3.0.*' specified for the 'file version' is not in the normal 'major.minor.build.revision' format

On the AssemblyVersionAttribute Class page at MSDN is the following:

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.

Note the bold section. Does anyone know why [assembly: AssemblyVersion("3.0.*")] (from my project) is not valid, but [assembly:AssemblyVersion("1.2.*")] (from the MSDN example) is valid?

In particular, I am curious to know if I can start with a non-zero major number, as the application that I am writing is version 3 of the program.

UPDATE >>> Sorry, this does seem to be answered in the other post... please vote to close it, thanks.


回答1:


You're assuming that the problem is with this line:

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

when it is actually with this one:

[assembly: AssemblyFileVersion("3.0.*")]

Like the accepted answer to the question that you say is not a duplicate of this one says:

For the AssemblyFileVersionAttribute you cannot use the * special character so you have to provide a full and valid version number.

That * syntax works only with the AssemblyVersion attribute. It doesn't work with the AssemblyFileVersion attribute.

There are two workarounds to achieve the results you probably desire here:

  1. Simply omit the AssemblyFileVersion attribute altogether. That will cause the assembly file version information to be automatically divined from the AssemblyVersion attribute (which is the one that does support the * syntax).

  2. Break out the big guns and install the Build Version Increment add-in, which offers you more version incrementing options than you can shake a stick at.



来源:https://stackoverflow.com/questions/15505841/cs1607-the-version-specified-for-the-file-version-is-not-in-the-normal-major

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!