Skip to content

dotnet package update should support max version ranges #14313

Closed as duplicate

Description

@zivkan

It's common for customers to want to use target their projects to an LTS version of .NET, and use the same major version packages for packages created from the dotnet/runtime repo. When a newer STS version of .NET is released, the highest package versions are no longer the LTS version the cusomter wants. When this happens, NuGet usually gets more upvotes on #5725, as well as new bug reports and new feature requests for this functionality. Also see #14312

A good enough alternative is to allow customers to mark their PackageReferences with an upper bound, and then dotnet package update will consider that when choosing a version

Questions:

  • Should this feature use PacakgeReference's existing Version= range attribute? For example, Version="[8.0.1, 9.0.0)" to allow upgrades to 8.0.2, but not 9.0.0? However, this this is also used by pack and project references, so it has a potentially unwanted side effect of causing NU1608 warnings on other projects that get this version constraint transitively.
  • If we introduce any other attribute, for example an AllowedUpdates="[8.0.0, 9.0.0)", then we'll have an incomplete experience with VS's update functionality not supporting the same thing.
  • If a customer specifies a specific version on the command line, should update remove the range and change it to the >= default?
  • When the customer is ready to update to a different max version range, should this be possible via dotnet package update, or in this "advanced" scenario, should we just tell customers to hand edit the msbuild file?

Activity

  1. Frulfump commented on Jun 24, 2025

    @Frulfump

    Could we also exclude specific packages from being updated altogether with this? (Without manually setting the range) like using something like this --exclude System.*?

  2. blowdart commented on Feb 5, 2026

    @blowdart
    Member

    I'd extend this a little further, where if you specify a range for a package, you can also (optionally) allow security updates to the package, even if it's outside of the allowed range.

  3. jbennink commented on Feb 20, 2026

    @jbennink

    Regarding point 1. I think this is already the case, at least in teh CPM Packageversion tag of Directory.Packages.props. The problem there is that after the package update from 8.01 to 8.02 it writes Version="8.02" overwriting the restriction. It would be better to have the update, update the lower-bound to the new version like [8.0.2, 9.0.0) so as to keep the restriction intact.

    Your second point was prevviously already supported with the "AllowedVersions" attribute of the Packagereference. Since I am referencing PackageVersion where this is not supported I guess that team chose to go another way, maybe because of the compatibility and fragmenetion that you mention.

    Regarding point 3 it would be helpful that a used trying to set a specific version would be allowed as long as it stays inside the restriction. It would then also be good to update the restriction lower-bound as I mentioned in my reply to point 1.

    And on your point 4 I think when a user want to install a lower version, or higher version than the active restriction it should give an error and not allow it. If tooling allows maybe a --force parameter this could ignore and overwrite the restriction but perhaps it is better, as you also suggest, to leave that to the user needing to remove or modify the restriction in the file it was set.

  4. nkolev92 commented on Feb 23, 2026

    @nkolev92
    Member

    Consolidating this into #6566 for now.

    There are 3 places where you can install packages in PR today, PMC, PM UI & dotnet package add/update, and ideally we have parity across the experiences.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions