.net 程序集的产品版本和文件版本在编译后不相同
Product Version and File version of .net assemblies are not same after compilation
我正在如下设置 .net 程序集的程序集和文件版本,
[assembly: AssemblyVersion("9.05.115.0")]
[assembly: AssemblyFileVersion("9.05.115.0")]
安装构建后,我正在查看已部署文件的文件详细信息。我发现产品版本正确显示为 9.05.115.0。
但是,文件版本显示为9.5.115.0。那么为什么文件版本中“05”没有前导零。
有什么原因吗?还是我遗漏了什么?
根据here:
The versions are stored internally as integers, so even if you append
0 to the start of the version number, it will be converted to an int
and removed.
和here:
The AssemblyVersion attribute stores it's information as a Version
object. The components of the Version struct are integers, and are
treated as such. So 1.2.3.4 == 1.02.003.004 but 1.2.3.4 != 1.2.3.400
You can use the AssemblyInformationalVersionAttribute to provide
aditional, arbitrarily formatted information about your product, as
it's information is stored as a string, rather than a Version. So you
can do:
[assembly: AssemblyVersion("1.1.1.102")] [assembly:
AssemblyInformationalVersion("v.01 alpha")]
Or whatever you like
我正在如下设置 .net 程序集的程序集和文件版本,
[assembly: AssemblyVersion("9.05.115.0")]
[assembly: AssemblyFileVersion("9.05.115.0")]
安装构建后,我正在查看已部署文件的文件详细信息。我发现产品版本正确显示为 9.05.115.0。
但是,文件版本显示为9.5.115.0。那么为什么文件版本中“05”没有前导零。
有什么原因吗?还是我遗漏了什么?
根据here:
The versions are stored internally as integers, so even if you append 0 to the start of the version number, it will be converted to an int and removed.
和here:
The AssemblyVersion attribute stores it's information as a Version object. The components of the Version struct are integers, and are treated as such. So 1.2.3.4 == 1.02.003.004 but 1.2.3.4 != 1.2.3.400
You can use the AssemblyInformationalVersionAttribute to provide aditional, arbitrarily formatted information about your product, as it's information is stored as a string, rather than a Version. So you can do:
[assembly: AssemblyVersion("1.1.1.102")] [assembly: AssemblyInformationalVersion("v.01 alpha")]
Or whatever you like