1

I am developing a .NET 6 web application and I have a requirement to set the ProductVersion (or, if that is impossible, at least FileVersion) of the assembly to a custom string, like shown here:

enter image description here

However, I can't figure out how to do it. All the versioning properties I see in the .csproj file seem to expect a specific numeric format like x.y.z or something similar.

Is there a way to do this in the .csproj file, without having to patch the final compiled assembly?

2
  • Have you seen this related post? Commented Dec 20, 2023 at 16:20
  • @AxelKemper: the answer in that post suggests using VersionPrefix+VersionSuffix. However, unfortunately VersionPrefix still needs to be in the form x.y.z, so with 3 pieces. In my case I need it to be only 2. I tried setting only 2 but in that case the compiler seems to add a .0 automatically at the end... I tried various combinations but I couldn't replicate the version string shown in the screenshot I posted. Commented Dec 20, 2023 at 16:54

1 Answer 1

2

It seems that InformationalVersion is mapped to ProductVersion:

<PropertyGroup>
    <InformationalVersion>1.24asdds</InformationalVersion>
</PropertyGroup>

Result:

enter image description here

If you are using .NET 8 SDK to build - do not forget to set IncludeSourceRevisionInInformationalVersion to false:

<PropertyGroup>
    <InformationalVersion>1.24asdds</InformationalVersion>
    <IncludeSourceRevisionInInformationalVersion>
         false
    </IncludeSourceRevisionInInformationalVersion>
</PropertyGroup>
Sign up to request clarification or add additional context in comments.

Comments

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.