8

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:

cpp-details

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:

cs-details

How can I set Product Version and File Version to different values in a C# DLL? I'm using Visual Studio 2019.

2 Answers 2

11

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for this answer. It's one of those things that can occupy days, especially since setting ProductVersion does something very different to what one might naturally expect.
1

When I edited my AssemblyInfo.cs files, and rebuilt, found that some of the values I'd just changed would get reset.

The soln was to edit the csproj file, and that took care of it!

1 Comment

edit the csproj file how? Which values did you set?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.