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.
- Create a class library project.
- Install Newtonsoft.Json 9.0.1 - using a packages.config file.
- Add a constraint to the packages.config file to ensure latest is not used:
allowedVersions="[9.0,11)"
. - 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 commentedon Jan 27, 2019
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.