问题
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\0"
#define VER_FILEVERSION 1,0,0,1
#define VER_FILEVERSION_STR "1.0.0.1\0"
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.
回答1:
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:
Note: If the AssemblyInformationalVersionAttribute attribute is not applied to an assembly, the version number specified by the AssemblyVersionAttribute attribute is used by the Application.ProductVersion, Application.UserAppDataPath, and Application.UserAppDataRegistry properties.
来源:https://stackoverflow.com/questions/60113511/set-product-version-and-file-version-to-different-numbers-in-c-sharp