简体   繁体   English

CS1607:程序集生成 - 为“文件版本”指定的版本“1.4.0.85725”不是正常的“major.minor.build.revision”格式

[英]CS1607: Assembly generation — The version '1.4.0.85725' specified for the 'file version' is not in the normal 'major.minor.build.revision' format

(Please excuse me if I get any terms mixed up here - I am a Java developer, new to .Net and C#. Please add/correct any tags on this question if need be.) (请原谅我在这里混淆了任何条款 - 我是Java开发人员,对.Net和C#不熟悉。如果需要,请在此问题上添加/更正任何标签。)

I am using an MSBuild script to build my project. 我正在使用MSBuild脚本来构建我的项目。 One of the tasks is to write the assembly info: 其中一个任务是编写程序集信息:

<Target Name="UpdateAssemblyInfo">
    <Message Text="Updating assemblies to file version $(AssemblyVersion) ($(AssemblyFileVersion))" Importance="high"/>
    <AssemblyInfo CodeLanguage="CS"
                  OutputFile="SharedAssemblyInfo.cs" 
                  AssemblyVersion="$(AssemblyVersion)"
                  AssemblyFileVersion="$(AssemblyFileVersion)"
                  AssemblyProduct="SVN revision $(BUILD_NUMBER)"/>
</Target>

This converts SharedAssemblyInfo.cs from this: 这将转换SharedAssemblyInfo.cs

[assembly: System.Reflection.AssemblyVersion("0.0.0")]

To this: 对此:

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.18063
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

[assembly: System.Reflection.AssemblyVersion("1.4.0")]
[assembly: System.Reflection.AssemblyFileVersion("1.4.0.85725")]
[assembly: System.Reflection.AssemblyProduct("SVN revision 85725")]

So far so good. 到现在为止还挺好。 Except I see the following message in the build log of TeamCity: 除了我在TeamCity的构建日志中看到以下消息:

CSC warning CS1607: Assembly generation -- The version '1.4.0.85725' specified for the 'file version' is not in the normal 'major.minor.build.revision' format CSC警告CS1607:程序集生成 - 为“文件版本”指定的版本“1.4.0.85725”不是正常的“major.minor.build.revision”格式

Why am I getting this warning, when the format of the version appears to follow the format specified in the warning message? 当版本的格式符合警告消息中指定的格式时,为什么会收到此警告?

您收到错误的原因是修订号大于65534。

Why am I getting this warning, when the format of the version appears to follow the format specified in the warning message? 当版本的格式符合警告消息中指定的格式时,为什么会收到此警告?

Re-read that warning, with some added emphasis: 重新阅读该警告,并重点强调:

the normal 'major.minor.build. 正常的'major.minor.build。 revision ' format 修订 '格式

.NET version numbers have FOUR parts, not three. .NET版本号有四个部分,而不是三个。

The System.Version type used for this will process versions of fewer types, but it is possible for code using System.Version to check and be stricter. 用于此的System.Version类型将处理更少类型的版本,但使用System.Version代码可以检查并更严格。

Additional, as noted by Mihai , elements of the version are limited to System.UInt16.MaxValue (65535): this is a Windows API limitation (in System.Version each element is a System.Int32 ) related to the native VS_FIXEDFILEINFO 1 resource that the compiler inserts into the assembly from various assembly attributes. 另外,如Mihai所述 ,该版本的元素仅限于System.UInt16.MaxValue (65535):这是与本机VS_FIXEDFILEINFO 1资源相关的Windows API限制(在System.Version中,每个元素是System.Int32 )编译器从各种程序集属性插入程序集。 This allows tools like Windows Explorer to read the version. 这允许Windows资源管理器等工具读取该版本。

Summary: 摘要:

  • There should be four parts to the version. 该版本应该有四个部分。
  • Each part should be in the range [0, 65535]. 每个部分应在[0,65535]范围内。

1 The version is stored across two DWORD members: one for Major and Minor parts, the other for Build and Revision (albeit not given those names in Win32). 1版本存储在两个DWORD成员中:一个用于主要和次要部分,另一个用于构建和修订(尽管在Win32中没有给出这些名称)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么警告CS1607“为&#39;产品版本&#39;指定的版本不是正常的&#39;major.minor.build.revision&#39;格式”生成的? - Why is warning CS1607 “The version specified for the 'product version' is not in the normal 'major.minor.build.revision' format” generated? 指定的版本字符串不符合要求的格式——major[.minor[.build[.revision]]] - The specified version string does not conform to the required format - major[.minor[.build[.revision]]] 关闭警告CS1607 - Turn off warning CS1607 NuSpec-如何将$ version $缩减为Major.Minor.Build(SemVersion)? - NuSpec - how to trim $version$ down to Major.Minor.Build (SemVersion)? 是否可以将.NET中的内部版本号和修订号切换为[主要]。[次要]。[补丁]。[内部] - Is it possible to switch build and revision number in .NET to [Major].[Minor].[Patch].[Build] Sharepoint 新文件上传版本保存为次要版本而不是主要版本 - Sharepoint new file upload version saved as Minor rather than Major version 构建版本与修订版号 - Build Version vs Revision number 使用Regex从AssemblyInfo.cs文件中检索程序集版本 - Retrieving Assembly version from AssemblyInfo.cs file with Regex 如何与其 DLL 共享主应用程序的主要和次要版本? - How to share major and minor version of the main application with its DLLs? gacutil和环境中的次要版本差异导致严重的麻烦 - Minor version difference in gacutil and environment causing major headaches
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM