![](/img/trans.png)
[英]Why is warning CS1607 “The version specified for the 'product version' is not in the normal 'major.minor.build.revision' format” generated?
[英]CS1607: Assembly generation — The version '1.4.0.85725' specified for the 'file version' is not in the normal 'major.minor.build.revision' format
(請原諒我在這里混淆了任何條款 - 我是Java開發人員,對.Net和C#不熟悉。如果需要,請在此問題上添加/更正任何標簽。)
我正在使用MSBuild腳本來構建我的項目。 其中一個任務是編寫程序集信息:
<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>
這將轉換SharedAssemblyInfo.cs
:
[assembly: System.Reflection.AssemblyVersion("0.0.0")]
對此:
//------------------------------------------------------------------------------
// <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")]
到現在為止還挺好。 除了我在TeamCity的構建日志中看到以下消息:
CSC警告CS1607:程序集生成 - 為“文件版本”指定的版本“1.4.0.85725”不是正常的“major.minor.build.revision”格式
當版本的格式符合警告消息中指定的格式時,為什么會收到此警告?
您收到錯誤的原因是修訂號大於65534。
當版本的格式符合警告消息中指定的格式時,為什么會收到此警告?
重新閱讀該警告,並重點強調:
正常的'major.minor.build。 修訂 '格式
.NET版本號有四個部分,而不是三個。
用於此的System.Version
類型將處理更少類型的版本,但使用System.Version
代碼可以檢查並更嚴格。
另外,如Mihai所述 ,該版本的元素僅限於System.UInt16.MaxValue
(65535):這是與本機VS_FIXEDFILEINFO
1資源相關的Windows API限制(在System.Version中,每個元素是System.Int32
)編譯器從各種程序集屬性插入程序集。 這允許Windows資源管理器等工具讀取該版本。
摘要:
1版本存儲在兩個DWORD
成員中:一個用於主要和次要部分,另一個用於構建和修訂(盡管在Win32中沒有給出這些名稱)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.