Search code examples
c#.netvisual-studionuget.net-6.0

.NET 6 project in Visual Studio offers update NuGet packages to 7.0.0


I have a .NET 6 ASP.NET Core project in VS 2022 and wonder if there is a way not to get .NET 7 packages in my NuGet update list? Or am I supposed to update NutGet packages to 7.0.X? What is the best practice?

NuGet package manager


Solution

  • Check dependencies for the corresponding packages. For example Microsoft.Extensions.DependencyInjection 7.0.0 specifies next supported frameworks and dependecies:

    • .NETFramework 4.6.2
      • Microsoft.Bcl.AsyncInterfaces (>= 7.0.0)
      • Microsoft.Extensions.DependencyInjection.Abstractions (>= 7.0.0)
      • System.Threading.Tasks.Extensions (>= 4.5.4)
    • .NETStandard 2.0
      • Microsoft.Bcl.AsyncInterfaces (>= 7.0.0)
      • Microsoft.Extensions.DependencyInjection.Abstractions (>= 7.0.0)
      • System.Threading.Tasks.Extensions (>= 4.5.4)
    • .NETStandard 2.1
      • Microsoft.Extensions.DependencyInjection.Abstractions (>= 7.0.0)
    • net6.0
      • Microsoft.Extensions.DependencyInjection.Abstractions (>= 7.0.0)
    • net7.0
      • Microsoft.Extensions.DependencyInjection.Abstractions (>= 7.0.0)

    But for example Microsoft.AspNetCore.Authentication.JwtBearer 7.0.0 is only supported only for .NET 7 (my guess would be that either all or almost all ASP.NET Core packages would behave the same way):

    • net7.0
      • Microsoft.IdentityModel.Protocols.OpenIdConnect (>= 6.15.1)

    So while in theory you can upgrade some of dependencies but definitely not all without updating target framework version. In general case I prefer to update either everything to the next major version or nothing (for packages supporting the "tied to runtime" versioning).