Description
NuGet Product(s) Involved
NuGet.exe, MSBuild.exe, dotnet.exe
The Elevator Pitch
According to SemVer2, 1.0.0 < 2.0.0-alpha < 2.0.0. But customers frequently use range [1.2.3, 2.0.0)
hoping to limit the range to 1.x
, but this doesn't take into account pre-release versions.
Therefore, I propose a warning when:
- it finds a package where an upper version is specified
- the upper version is not inclusive (
)
rather than]
) - the upper version does not have a prerelease label, then a warning is shown.
Something similar to:
Warning NUxxxx: Package Contoso.Utilities requests versions [1.2.3, 2.0.0) but will match pre-release version such as 2.0.0-alpha. To exclude prerelease versions, change the version range to [1.2.3, 2.0.0-0)
I'm not sure if this should only be a pack warning (dependency version), only be a restore warning (PackageReference version), or both.
Additional Context and Details
Consider issues like:
- NU1608 warning is not evaluating prerelease versions combined with exclusive upper bounds properly #6434
- [Bug]: VersionRange [1.0.0, 2.0.0) matches version 2.0.0-alpha.1 which can break package graphs #12082
I agree that the behaviour is non-intuitive, and that many customers would prefer the version range comparison to exclude the pre-release versions instead, but it's a breaking change whose magnitude of impact is unknown. This proposal could help package authors in particular minimize risk that their packages claim compatibility with pre-release packages.