-
Notifications
You must be signed in to change notification settings - Fork 266
Description
NuGet Product Used
dotnet.exe
Product Version
NuGet 6.12 and above has the problem
Worked before?
NuGet 6.11
Impact
I'm unable to use this version
Repro Steps & Context
Given a project with the following dependencies, the restore results are different:
NU1608 only
+ [0] {Microsoft.Maui.Essentials (>= 10.0.0) all} NuGet.LibraryModel.LibraryDependency
+ [1] {Microsoft.Maui.Controls (>= 10.0.0) all} NuGet.LibraryModel.LibraryDependency
+ [2] {CommunityToolkit.Maui (>= 12.2.0) all} NuGet.LibraryModel.LibraryDependencyNU1608 and Nu1107
+ [0] {Microsoft.Maui.Essentials (>= 10.0.0) all} NuGet.LibraryModel.LibraryDependency
+ [1] {CommunityToolkit.Maui (>= 12.2.0) all} NuGet.LibraryModel.LibraryDependency
+ [2] {Microsoft.Maui.Controls (>= 10.0.0) all} NuGet.LibraryModel.LibraryDependencyThe problem is basically which conflict we see first.
We dedup incorrectly during the flattening stage.
This is a flattening bug, not a resolved package calculation bug.
https://github.com/NuGet/NuGet.Client/tree/dev-nkolev92-randomDebug has an idea for a bug fix.
The test that validates this bug is the following:
// Project -> B 1.0.0
// -> C [1.0.0, 2.0.0)
// -> D [1.0.0, 2.0.0)
// -> A [1.0.0, 2.0.0)
// -> A 2.0.0 -> C 2.0.0 -> D 2.0.0
// -> D 2.0.0
[Theory]
[InlineData("\"D\":\"2.0.0\",\r\n\"A\":\"2.0.0\",\r\n\"B\":\"1.0.0\",")]
[InlineData("\"D\":\"2.0.0\",\r\n\"B\":\"1.0.0\",\r\n\"A\":\"2.0.0\",")]
public async Task RestoreCommand_WhenGraphHasAnUnresolvableRangeConflict_RaisesNU1107_VerifiesEquivalency(string deps)
{
// Arrange
using var pathContext = new SimpleTestPathContext();
var D = new SimpleTestPackageContext("D", "2.0.0");
var C = new SimpleTestPackageContext("C", "2.0.0")
{
Dependencies =
[
D,
]
};
var B = new SimpleTestPackageContext("B", "1.0.0")
{
Dependencies =
[
new SimpleTestPackageContext("C", "[1.0.0, 2.0.0)"),
new SimpleTestPackageContext("D", "[1.0.0, 2.0.0)"),
new SimpleTestPackageContext("A", "[1.0.0, 2.0.0)"),
]
};
var A = new SimpleTestPackageContext("A", "2.0.0")
{
Dependencies =
[
C,
]
};
await SimpleTestPackageUtility.CreatePackagesWithoutDependenciesAsync(pathContext.PackageSource,
B,
A,
C,
D);
// Switch the order in which A & B are declared
var projectSpec = @"
{
""frameworks"": {
""net10.0"": {
""dependencies"": {
DEPS
}
}
}
}".Replace("DEPS", deps);
var packageSpec = ProjectTestHelpers.GetPackageSpecWithProjectNameAndSpec("Project", pathContext.SolutionRoot, projectSpec);
// Act & Assert
(var result, _) = await ValidateRestoreAlgorithmEquivalency(pathContext, packageSpec);
}Note that even with the fix, the test currently fails because of a chosen package, not because of the warnings.
Given that this is an error scenario, the warning concern is lesser.