问题描述
在 C++ 项目中,我可以使用
我在 C# 项目中无法实现相同的目标.我在 AssemblyInfo.cs 文件中设置了以下内容:
[程序集:AssemblyVersion("1.0")][程序集:AssemblyFileVersion("1.0.0.1")]
但是,在DLL属性中,两者都设置为File Version的值:
如何在 C# DLL 中将产品版本和文件版本设置为不同的值?我使用的是 Visual Studio 2019.
您可以使用 AssemblyInformationalVersion
属性设置产品版本"信息中显示的值.在您的 Assembly.cs
文件中像这样设置:
[程序集:AssemblyInformationalVersion("1.2.3.4")]
来自 Microsoft 文档:
注意:如果 AssemblyInformationalVersionAttribute 属性不是应用于程序集,由指定的版本号AssemblyVersionAttribute 属性由Application.ProductVersion、Application.UserAppDataPath 和Application.UserAppDataRegistry 属性.
In a C++ project, I can add different Product Version and File Version values to my assembly using VERSIONINFO in a Version resource file:
#define VER_PRODUCTVERSION 1,0,0,0
#define VER_PRODUCTVERSION_STR "1.0 "
#define VER_FILEVERSION 1,0,0,1
#define VER_FILEVERSION_STR "1.0.0.1 "
This appears in the DLL properties as:
I'm having trouble achieving the same in a C# project. I've set the following in the AssemblyInfo.cs file:
[assembly: AssemblyVersion("1.0")]
[assembly: AssemblyFileVersion("1.0.0.1")]
However, in the DLL properties, both are set to the value of File Version:
How can I set Product Version and File Version to different values in a C# DLL? I'm using Visual Studio 2019.
You can set the value displayed in the "Product Version" info using the AssemblyInformationalVersion
attribute. Set this in your Assembly.cs
file like this:
[assembly: AssemblyInformationalVersion("1.2.3.4")]
From the Microsoft documentation:
这篇关于在 C# 中将产品版本和文件版本设置为不同的数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!