-
Couldn't load subscription status.
- Fork 120
Multiple installed versions of the same package are not handled correctly #1143
Description
🐛 Bug Report
Nukeeper does find all packages to update, if multiple versions of the same package are in use.
Expected behavior
All package updates are found.
Reproduction steps
In an empty folder, create two projects with a single package reference for different versions of the same package:
dotnet new console -o a
dotnet new console -o b
dotnet add .\a\a.csproj package xunit -v 2.4.0
dotnet add .\b\b.csproj package xunit
Running nuget inspect shows:
Found 2 packages
Found 2 packages in use, 1 distinct, in 2 projects.
xunit
Found 0 possible updates
Found no package updates
I expect it to find the update xunit 2.4.0 -> xunit 2.4.1 in project a. The update command has the same problem.
Configuration
Version: 0.35.0
Platform if applicable:
- 🛠️ NuKeeper CLI
- ✨ GitHub
- 🤖 AzureDevops
- 🏁 Bitbucket
- 🌎 Gitlab
- 📺 Gitea
- 🐳 Docker
Preliminary debugging
I think the method BulkPackageLookup.FindVersionUpdates does not handle this situation correctly.
In the example case, the packages parameter contains xunit.2.4.0 and xunit.2.4.1, as I would expect. The statement starting from line 32 checks updates for only the highest version of each package.
The code probably intended to call FindVersionUpdate only once per package. Reducing the amount of lookups is good, but at the same time the implementation ignores the non-highest installed versions of the same package.
Some variations in behavior:
If installed version are 2.3.0 and 2.4.0: One update is shown (2.4.0 -> 2.4.1). Expected two updates.
If installed versions are 1.9.0 and 2.4.1: No updates are shown. Expected one update.
If installed versions are 1.9.0 and 2.4.1, and allowed change is minor: Two updates are shown, as expected.
Workaround: running nuget inspect for only single project, instead of multiple projects, will show the update as expected.
There is a test for this situation. I think the assertions are not correct.