visual-studionuget

Suppress .NET 9-Related NuGet Updates in Visual Studio NuGet Package Manager


I am using Visual Studio 2022 for developing .NET C# projects, and I currently target .NET 8. Since the release of .NET 9, the NuGet Package Manager in Visual Studio offers updates for Microsoft packages in version 9.0.0. However, I want to stick with versions starting with 8.x.x while targeting .NET 8.

For example, I am currently using the package Microsoft.EntityFrameworkCore version 8.0.11. I would like to:

  1. Exclude version 9.x.x updates from appearing in the list of available updates in the NuGet Package Manager.
  2. Receive notifications only for patch updates within the 8.x.x range, such as a hypothetical version 8.0.12.

Is there a way to configure Visual Studio or the NuGet configuration to suppress updates outside the 8.x.x range while still being notified of updates relevant to .NET 8?


Solution

  • Is there a way to configure Visual Studio or the NuGet configuration to suppress updates outside the 8.x.x range while still being notified of updates relevant to .NET 8?

    Yes, you can use Package versioning to exclude version 9.x.x updates from appearing in the list of available updates in the NuGet Package Manager.

     <ItemGroup>
        <PackageReference Include="Microsoft.EntityFrameworkCore" Version="[8.0.11,9.0.0)" />
      </ItemGroup>
    

    It will accepts any 8.0.11 higher version, but not 9.x and higher. enter image description here