Skip to content

Get-Package -Updates ignores constraints #7737

Open
@mrward

Description

Details about Problem

NuGet product used (NuGet.exe | VS UI | Package Manager Console | dotnet.exe): Package Manager Console

NuGet version (x.x.x.xxx): 4.9.2.5706

dotnet.exe --version (if appropriate):

VS version (if appropriate): 15.9.4

OS version (i.e. win10 v1607 (14393.321)):

Worked before? If so, with which NuGet version:

Detailed repro steps so we can see the same problem

Adding a constraint to a packages.config file to limit the allowed versions does not seem to have any affect on Get-Package -Updates.

  1. Create a class library project.
  2. Install Newtonsoft.Json 9.0.1 - using a packages.config file.
  3. Add a constraint to the packages.config file to ensure latest is not used: allowedVersions="[9.0,11)".
  4. Run Get-Package -Updates

Expected result:

Version 10.0.3 is shown in the output.

Actual result:

12.0.1 is shown in the Package Console output.
The Manage Packages information shows the correct update of 10.0.3 being available.
...

Other suggested things

Verbose Logs

Please include verbose logs (NuGet.exe -verbosity detailed | dotnet.exe --verbosity diag | etc...)

Sample Project

Very helpful if you can zip a project and paste into this issue!

Activity

mrward

mrward commented on Jan 27, 2019

@mrward
MemberAuthor

Ignoring #7738 for the moment - and only having one project so the default project is always the correct one to use. Looking at the code the correct highest available version is found in the MultiSourcePackageMetadataProvider when the constraint is applied at this point:

https://github.com/NuGet/NuGet.Client/blob/8d300225298df9c6af6c784efffa7522109f0096/src/NuGet.Clients/NuGet.PackageManagement.VisualStudio/PackageFeeds/MultiSourcePackageMetadataProvider.cs#L101

However this information is then merged with all versions for the package - the latest allowed seems to be ignored. GetVersionsAsync returns all versions for the package identity:

https://github.com/NuGet/NuGet.Client/blob/8d300225298df9c6af6c784efffa7522109f0096/src/NuGet.Clients/NuGet.PackageManagement.VisualStudio/PackageFeeds/MultiSourcePackageMetadataProvider.cs#L169

So all versions are returned.

ghost added
Status:InactiveIcebox issues not updated for a specific long time
on Sep 1, 2022
added
Priority:3Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog.
and removed on Apr 3, 2024
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

      Get-Package -Updates ignores constraints · Issue #7737 · NuGet/Home