gpt4 book ai didi

c# - AssemblyInformationalVersion 属性行为更改 : deliberate or a bug?

转载 作者:行者123 更新时间:2023-11-30 12:42:15 26 4
gpt4 key购买 nike

在使用 VS2013 构建的 C# 项目中,我可以将其放入 AssemblyInfo.cs 文件中:

[assembly: AssemblyInformationalVersion("7.1.0.0 Private (Debug build)")]

当我对另一个项目中的可执行文件使用 FileVersionInfo.GetVersionInfo .NET API 时,我发现报告了这些值:

  • 产品版本:7.1.0.0 Private(调试版本)
  • 产品主要部分:7
  • 产品次要部分:1

当我在使用 VS2015 构建的 C# 项目中使用相同的属性和字符串值时,ProductMajorPart 和 ProductMinorPart 属性报告为零!

有谁知道行为改变是否是故意的?

我检查了可执行文件中的二进制文件版本信息,虽然版本信息中的字符串值在两个文件中都符合预期,但 VS2015 可执行文件在 VS_FIXEDFILEINFO.dwProductVersionMS 和 VS_FIXEDFILEINFO.dwProductVersionLS 字段中的值为零。

最佳答案

我可以确认这种情况下的行为变化,观察到如果 AssemblyInformationalVersion 是规范格式,例如 "7.1.0.0" 那么它就可以工作正如在所有版本中预期的那样,即填写了产品版本主要/次要/构建/修订字段。

对于背景,docs for AssemblyInformationalVersion做事实上指定:

The attribute defined by this class attaches additional version information to an assembly. If this attribute is applied to an assembly, the string it specifies can be obtained at run time by using the Application.ProductVersion property.

[...] Although you can specify any text, a warning message appears on compilation if the string is not in the format used by the assembly version number [...]

从上面:

  • 除了 string 本身可以被检索外,没有任何正式的保证;

  • 存在针对使用自由格式字符串的警告。

您可以,甚至应该在 VS connect 上提交错误报告尽管我的感觉是 MS 将 AssemblyInformationalVersion 中的自由格式字符串视为不受支持的“意外”功能,并且可能不会将未记录行为的更改视为适当的“错误”。

没有直接关系,但是这个 VS 2010 错误报告 Localized build with free form AssemblyInformationalVersion causes ALINK warning AL1053已被 MS 关闭,因为 won't fix

也是在 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 格式,您就只能靠自己了。

关于c# - AssemblyInformationalVersion 属性行为更改 : deliberate or a bug?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34361877/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com