Search code examples
visual-studionugetnuget-packagevisual-studio-2022

Assembly version option missing in VS 2022 .NET 6


In a .NET Framework class library I was able to right click the project > properties and click Assembly Version, update the version and that was part of the build once the dll was available. I then used this version when building a NuGet package.

In Visual Studio 2022 i have a .NET 6 Class Library but when I right click I don't see the same Assembly Version option though I see it under Package but i cant tell if this works the same as Assembly Version or if Package is just for NuGet.

What would be the correct place to increase the Assembly Version so it takes place on the Class Library and any NuGet package i build?


Solution

  • From Migrating from .NET Framework section of MSBuild reference for .NET SDK projects docs:

    .NET Framework project templates create a code file with these assembly info attributes set. The file is typically located at .\Properties\AssemblyInfo.cs or .\Properties\AssemblyInfo.vb. SDK-style projects generate this file for you based on the project settings. You can't have both. When porting your code to .NET 5 (or .NET Core 3.1) or later, do one of the following:

    • Disable the generation of the temporary code file that contains the assembly info attributes by setting GenerateAssemblyInfo to false in your project file. This enables you to keep your AssemblyInfo file.
    • Migrate the settings in the AssemblyInfo file to the project file, and then delete the AssemblyInfo file.

    So you can bring this file back if you want by adding the following to .csproj and adding corresponding file to the solution:

    <PropertyGroup>
      <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
    </PropertyGroup>
    

    Or just managing the properties in the .csproj itself.

    If you edit data in the Package you will see that it will manage the appropriate settings (though naming is not ideal, yes).