You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
dotnet package update should support max version ranges #14313
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?
Reacted by Frulfump, cremor, Gert, Barry Dorrans and Johan Bennink
Could we also exclude specific packages from being updated altogether with this? (Without manually setting the range) like using something like this --exclude System.*?
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.
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.
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.
Activity
dotnet package updateto specific versions #14381 as a duplicate of this issueFrulfump commentedon Jun 24, 2025
Could we also exclude specific packages from being updated altogether with this? (Without manually setting the range) like using something like this
--exclude System.*?blowdart commentedon Feb 5, 2026
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.
jbennink commentedon Feb 20, 2026
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 pointwas 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 3it 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 topoint 1.And on your
point 4I 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--forceparameter 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.nkolev92 commentedon Feb 23, 2026
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.