Skip to content

Warning when version range upper version does not end in -0 #12423

Open
@zivkan

Description

@zivkan

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:

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions