dependabot-nuget 0.290.0 → 0.292.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/helpers/lib/NuGetUpdater/.editorconfig +1 -0
  3. data/helpers/lib/NuGetUpdater/Directory.Build.props +1 -0
  4. data/helpers/lib/NuGetUpdater/Directory.Packages.props +1 -1
  5. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/AnalyzeCommand.cs +1 -1
  6. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/CloneCommand.cs +1 -1
  7. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/DiscoverCommand.cs +15 -1
  8. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/RunCommand.cs +2 -2
  9. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/UpdateCommand.cs +1 -1
  10. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Analyze.cs +2 -1
  11. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Discover.cs +87 -3
  12. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Update.cs +1 -1
  13. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/AnalyzeWorker.cs +14 -0
  14. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/DependencyFinder.cs +2 -0
  15. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/RequirementConverter.cs +19 -1
  16. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/BadRequirementException.cs +9 -0
  17. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Clone/CloneWorker.cs +39 -8
  18. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DiscoveryWorker.cs +111 -17
  19. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/PackagesConfigDiscovery.cs +2 -2
  20. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/ProjectDiscoveryResult.cs +2 -0
  21. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/SdkProjectDiscovery.cs +19 -11
  22. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/ErrorType.cs +2 -0
  23. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/ExperimentsManager.cs +31 -5
  24. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/NuGetUpdater.Core.csproj +1 -0
  25. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/BadRequirement.cs +10 -0
  26. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/CommitOptions.cs +1 -1
  27. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/DependencyFileNotFound.cs +3 -2
  28. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/JobErrorBase.cs +1 -2
  29. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/JobRepoNotFound.cs +1 -4
  30. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/PrivateSourceAuthenticationFailure.cs +1 -1
  31. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/UnknownError.cs +6 -2
  32. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/UpdateNotPossible.cs +1 -1
  33. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/RunWorker.cs +9 -3
  34. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/LockFileUpdater.cs +3 -2
  35. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/PackageReferenceUpdater.cs +43 -18
  36. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/UpdaterWorker.cs +1 -1
  37. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/WebApplicationTargetsConditionPatcher.cs +12 -1
  38. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/DependencyConflictResolver.cs +0 -7
  39. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/MSBuildHelper.cs +48 -17
  40. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/NuGetHelper.cs +2 -2
  41. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/ProcessExtensions.cs +45 -7
  42. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/ProjectHelper.cs +4 -4
  43. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Clone/CloneWorkerTests.cs +60 -2
  44. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTestBase.cs +10 -1
  45. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.PackagesConfig.cs +56 -0
  46. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.cs +41 -0
  47. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/ExpectedDiscoveryResults.cs +2 -0
  48. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/SdkProjectDiscoveryTests.cs +1 -1
  49. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/MockNuGetPackage.cs +2 -1
  50. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/RunWorkerTests.cs +1 -1
  51. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/SerializationTests.cs +76 -40
  52. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTestBase.cs +20 -2
  53. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.GlobalJson.cs +2 -2
  54. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.LockFile.cs +251 -0
  55. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackageReference.cs +6 -6
  56. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackagesConfig.cs +63 -5
  57. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/MSBuildHelperTests.cs +277 -73
  58. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/ProjectHelperTests.cs +65 -0
  59. data/helpers/lib/NuGetUpdater/global.json +1 -1
  60. data/lib/dependabot/nuget/file_fetcher.rb +1 -0
  61. data/lib/dependabot/nuget/file_parser.rb +90 -0
  62. data/lib/dependabot/nuget/language.rb +98 -0
  63. data/lib/dependabot/nuget/native_helpers.rb +25 -0
  64. data/lib/dependabot/nuget/package_manager.rb +51 -0
  65. metadata +12 -6
@@ -147,8 +147,10 @@ public class MSBuildHelperTests : TestBase
147
147
  AssertEx.Equal(expectedTopLevelDependencies, actualTopLevelDependencies);
148
148
  }
149
149
 
150
- [Fact]
151
- public async Task AllPackageDependenciesCanBeTraversed()
150
+ [Theory]
151
+ [InlineData(true)]
152
+ [InlineData(false)]
153
+ public async Task AllPackageDependenciesCanBeTraversed(bool useExistingSdks)
152
154
  {
153
155
  using var temp = new TemporaryDirectory();
154
156
  MockNuGetPackage[] testPackages =
@@ -173,13 +175,16 @@ public class MSBuildHelperTests : TestBase
173
175
  temp.DirectoryPath,
174
176
  "netstandard2.0",
175
177
  [new Dependency("Package.A", "1.0.0", DependencyType.Unknown)],
178
+ new ExperimentsManager() { InstallDotnetSdks = useExistingSdks },
176
179
  new TestLogger()
177
180
  );
178
181
  AssertEx.Equal(expectedDependencies, actualDependencies);
179
182
  }
180
183
 
181
- [Fact]
182
- public async Task AllPackageDependencies_DoNotTruncateLongDependencyLists()
184
+ [Theory]
185
+ [InlineData(true)]
186
+ [InlineData(false)]
187
+ public async Task AllPackageDependencies_DoNotTruncateLongDependencyLists(bool useExistingSdks)
183
188
  {
184
189
  using var temp = new TemporaryDirectory();
185
190
  MockNuGetPackage[] testPackages =
@@ -301,7 +306,14 @@ public class MSBuildHelperTests : TestBase
301
306
  new Dependency("Package.2A", "1.0.0", DependencyType.Unknown),
302
307
  new Dependency("Package.2R", "18.0.0", DependencyType.Unknown),
303
308
  };
304
- var actualDependencies = await MSBuildHelper.GetAllPackageDependenciesAsync(temp.DirectoryPath, temp.DirectoryPath, "net8.0", packages, new TestLogger());
309
+ var actualDependencies = await MSBuildHelper.GetAllPackageDependenciesAsync(
310
+ temp.DirectoryPath,
311
+ temp.DirectoryPath,
312
+ "net8.0",
313
+ packages,
314
+ new ExperimentsManager() { InstallDotnetSdks = useExistingSdks },
315
+ new TestLogger()
316
+ );
305
317
  for (int i = 0; i < actualDependencies.Length; i++)
306
318
  {
307
319
  var ad = actualDependencies[i];
@@ -312,8 +324,10 @@ public class MSBuildHelperTests : TestBase
312
324
  AssertEx.Equal(expectedDependencies, actualDependencies);
313
325
  }
314
326
 
315
- [Fact]
316
- public async Task AllPackageDependencies_DoNotIncludeUpdateOnlyPackages()
327
+ [Theory]
328
+ [InlineData(true)]
329
+ [InlineData(false)]
330
+ public async Task AllPackageDependencies_DoNotIncludeUpdateOnlyPackages(bool useExistingSdks)
317
331
  {
318
332
  using var temp = new TemporaryDirectory();
319
333
  MockNuGetPackage[] testPackages =
@@ -335,12 +349,21 @@ public class MSBuildHelperTests : TestBase
335
349
  new Dependency("Package.B", "2.0.0", DependencyType.Unknown, TargetFrameworks: ["net8.0"]),
336
350
  new Dependency("Package.C", "3.0.0", DependencyType.Unknown, IsUpdate: true)
337
351
  };
338
- var actualDependencies = await MSBuildHelper.GetAllPackageDependenciesAsync(temp.DirectoryPath, temp.DirectoryPath, "net8.0", packages, new TestLogger());
352
+ var actualDependencies = await MSBuildHelper.GetAllPackageDependenciesAsync(
353
+ temp.DirectoryPath,
354
+ temp.DirectoryPath,
355
+ "net8.0",
356
+ packages,
357
+ new ExperimentsManager() { InstallDotnetSdks = useExistingSdks },
358
+ new TestLogger()
359
+ );
339
360
  AssertEx.Equal(expectedDependencies, actualDependencies);
340
361
  }
341
362
 
342
- [Fact]
343
- public async Task GetAllPackageDependencies_NugetConfigInvalid_DoesNotThrow()
363
+ [Theory]
364
+ [InlineData(true)]
365
+ [InlineData(false)]
366
+ public async Task GetAllPackageDependencies_NugetConfigInvalid_DoesNotThrow(bool useExistingSdks)
344
367
  {
345
368
  using var temp = new TemporaryDirectory();
346
369
 
@@ -362,12 +385,15 @@ public class MSBuildHelperTests : TestBase
362
385
  temp.DirectoryPath,
363
386
  "net8.0",
364
387
  [new Dependency("Some.Package", "4.5.11", DependencyType.Unknown)],
388
+ new ExperimentsManager() { InstallDotnetSdks = useExistingSdks },
365
389
  new TestLogger()
366
390
  );
367
391
  }
368
392
 
369
- [Fact]
370
- public async Task LocalPackageSourcesAreHonored()
393
+ [Theory]
394
+ [InlineData(true)]
395
+ [InlineData(false)]
396
+ public async Task LocalPackageSourcesAreHonored(bool useExistingSdks)
371
397
  {
372
398
  using var temp = new TemporaryDirectory();
373
399
 
@@ -402,14 +428,17 @@ public class MSBuildHelperTests : TestBase
402
428
  temp.DirectoryPath,
403
429
  "net8.0",
404
430
  [new Dependency("Package.A", "1.0.0", DependencyType.Unknown)],
431
+ new ExperimentsManager() { InstallDotnetSdks = useExistingSdks },
405
432
  new TestLogger()
406
433
  );
407
434
 
408
435
  AssertEx.Equal(expectedDependencies, actualDependencies);
409
436
  }
410
437
 
411
- [Fact]
412
- public async Task DependencyConflictsCanBeResolvedWithBruteForce()
438
+ [Theory]
439
+ [InlineData(true)]
440
+ [InlineData(false)]
441
+ public async Task DependencyConflictsCanBeResolvedWithBruteForce(bool useExistingSdks)
413
442
  {
414
443
  var repoRoot = Directory.CreateTempSubdirectory($"test_{nameof(DependencyConflictsCanBeResolvedWithBruteForce)}_");
415
444
  MockNuGetPackage[] testPackages =
@@ -450,7 +479,14 @@ public class MSBuildHelperTests : TestBase
450
479
  {
451
480
  new Dependency("Some.Other.Package", "1.2.0", DependencyType.PackageReference),
452
481
  };
453
- var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflictsWithBruteForce(repoRoot.FullName, projectPath, "net8.0", dependencies, new TestLogger());
482
+ var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflictsWithBruteForce(
483
+ repoRoot.FullName,
484
+ projectPath,
485
+ "net8.0",
486
+ dependencies,
487
+ new ExperimentsManager() { InstallDotnetSdks = useExistingSdks },
488
+ new TestLogger()
489
+ );
454
490
  Assert.NotNull(resolvedDependencies);
455
491
  Assert.Equal(2, resolvedDependencies.Length);
456
492
  Assert.Equal("Some.Package", resolvedDependencies[0].Name);
@@ -505,8 +541,10 @@ public class MSBuildHelperTests : TestBase
505
541
  #region
506
542
  // Updating root package
507
543
  // CS-Script Code to 2.0.0 requires its dependency Microsoft.CodeAnalysis.CSharp.Scripting to be 3.6.0 and its transitive dependency Microsoft.CodeAnalysis.Common to be 3.6.0
508
- [Fact]
509
- public async Task DependencyConflictsCanBeResolvedNewUpdatingTopLevelPackage()
544
+ [Theory]
545
+ [InlineData(true)]
546
+ [InlineData(false)]
547
+ public async Task DependencyConflictsCanBeResolvedNewUpdatingTopLevelPackage(bool useExistingSdks)
510
548
  {
511
549
  using var tempDirectory = new TemporaryDirectory();
512
550
  var projectPath = Path.Join(tempDirectory.DirectoryPath, "project.csproj");
@@ -535,7 +573,15 @@ public class MSBuildHelperTests : TestBase
535
573
  new Dependency("CS-Script.Core", "2.0.0", DependencyType.PackageReference),
536
574
  };
537
575
 
538
- var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(tempDirectory.DirectoryPath, projectPath, "net8.0", dependencies, update, new TestLogger());
576
+ var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(
577
+ tempDirectory.DirectoryPath,
578
+ projectPath,
579
+ "net8.0",
580
+ dependencies,
581
+ update,
582
+ new ExperimentsManager() { InstallDotnetSdks = useExistingSdks },
583
+ new TestLogger()
584
+ );
539
585
  Assert.NotNull(resolvedDependencies);
540
586
  Assert.Equal(3, resolvedDependencies.Length);
541
587
  Assert.Equal("CS-Script.Core", resolvedDependencies[0].Name);
@@ -547,8 +593,10 @@ public class MSBuildHelperTests : TestBase
547
593
  }
548
594
 
549
595
  // Updating a dependency (Microsoft.Bcl.AsyncInterfaces) of the root package (Azure.Core) will require the root package to also update, but since the dependency is not in the existing list, we do not include it
550
- [Fact]
551
- public async Task DependencyConflictsCanBeResolvedNewUpdatingNonExistingDependency()
596
+ [Theory]
597
+ [InlineData(true)]
598
+ [InlineData(false)]
599
+ public async Task DependencyConflictsCanBeResolvedNewUpdatingNonExistingDependency(bool useExistingSdks)
552
600
  {
553
601
  using var tempDirectory = new TemporaryDirectory();
554
602
  var projectPath = Path.Join(tempDirectory.DirectoryPath, "project.csproj");
@@ -572,7 +620,15 @@ public class MSBuildHelperTests : TestBase
572
620
  new Dependency("Microsoft.Bcl.AsyncInterfaces", "1.1.1", DependencyType.Unknown)
573
621
  };
574
622
 
575
- var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(tempDirectory.DirectoryPath, projectPath, "net8.0", dependencies, update, new TestLogger());
623
+ var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(
624
+ tempDirectory.DirectoryPath,
625
+ projectPath,
626
+ "net8.0",
627
+ dependencies,
628
+ update,
629
+ new ExperimentsManager() { InstallDotnetSdks = useExistingSdks },
630
+ new TestLogger()
631
+ );
576
632
  Assert.NotNull(resolvedDependencies);
577
633
  Assert.Single(resolvedDependencies);
578
634
  Assert.Equal("Azure.Core", resolvedDependencies[0].Name);
@@ -582,8 +638,10 @@ public class MSBuildHelperTests : TestBase
582
638
  // Adding a reference
583
639
  // Newtonsoft.Json needs to update to 13.0.1. Although Newtonsoft.Json.Bson can use the original version of 12.0.1, for security vulnerabilities and
584
640
  // because there is no later version of Newtonsoft.Json.Bson 1.0.2, Newtonsoft.Json would be added to the existing list to prevent resolution
585
- [Fact]
586
- public async Task DependencyConflictsCanBeResolvedNewUpdatingNonExistentDependencyAndKeepingReference()
641
+ [Theory]
642
+ [InlineData(true)]
643
+ [InlineData(false)]
644
+ public async Task DependencyConflictsCanBeResolvedNewUpdatingNonExistentDependencyAndKeepingReference(bool useExistingSdks)
587
645
  {
588
646
  using var tempDirectory = new TemporaryDirectory();
589
647
  var projectPath = Path.Join(tempDirectory.DirectoryPath, "project.csproj");
@@ -607,7 +665,15 @@ public class MSBuildHelperTests : TestBase
607
665
  new Dependency("Newtonsoft.Json", "13.0.1", DependencyType.Unknown)
608
666
  };
609
667
 
610
- var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(tempDirectory.DirectoryPath, projectPath, "net8.0", dependencies, update, new TestLogger());
668
+ var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(
669
+ tempDirectory.DirectoryPath,
670
+ projectPath,
671
+ "net8.0",
672
+ dependencies,
673
+ update,
674
+ new ExperimentsManager() { InstallDotnetSdks = useExistingSdks },
675
+ new TestLogger()
676
+ );
611
677
  Assert.NotNull(resolvedDependencies);
612
678
  Assert.Equal(2, resolvedDependencies.Length);
613
679
  Assert.Equal("Newtonsoft.Json.Bson", resolvedDependencies[0].Name);
@@ -620,8 +686,10 @@ public class MSBuildHelperTests : TestBase
620
686
  // Root package (Microsoft.CodeAnalysis.Compilers) and its dependencies (Microsoft.CodeAnalysis.CSharp), (Microsoft.CodeAnalysis.VisualBasic) are all 4.9.2
621
687
  // These packages all require the transitive dependency of the root package (Microsoft.CodeAnalysis.Common) to be 4.9.2, but it's not in the existing list
622
688
  // If Microsoft.CodeAnalysis.Common is updated to 4.10.0, everything else updates and Microsoft.CoseAnalysis.Common is not kept in the existing list
623
- [Fact]
624
- public async Task DependencyConflictsCanBeResolvedNewTransitiveDependencyNotExisting()
689
+ [Theory]
690
+ [InlineData(true)]
691
+ [InlineData(false)]
692
+ public async Task DependencyConflictsCanBeResolvedNewTransitiveDependencyNotExisting(bool useExistingSdks)
625
693
  {
626
694
  using var tempDirectory = new TemporaryDirectory();
627
695
  var projectPath = Path.Join(tempDirectory.DirectoryPath, "project.csproj");
@@ -649,7 +717,15 @@ public class MSBuildHelperTests : TestBase
649
717
  new Dependency("Microsoft.CodeAnalysis.Common", "4.10.0", DependencyType.PackageReference)
650
718
  };
651
719
 
652
- var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(tempDirectory.DirectoryPath, projectPath, "net8.0", dependencies, update, new TestLogger());
720
+ var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(
721
+ tempDirectory.DirectoryPath,
722
+ projectPath,
723
+ "net8.0",
724
+ dependencies,
725
+ update,
726
+ new ExperimentsManager() { InstallDotnetSdks = useExistingSdks },
727
+ new TestLogger()
728
+ );
653
729
  Assert.NotNull(resolvedDependencies);
654
730
  Assert.Equal(3, resolvedDependencies.Length);
655
731
  Assert.Equal("Microsoft.CodeAnalysis.Compilers", resolvedDependencies[0].Name);
@@ -662,8 +738,10 @@ public class MSBuildHelperTests : TestBase
662
738
 
663
739
  // Updating referenced dependency
664
740
  // The same as previous test, but the transitive dependency (Microsoft.CodeAnalysis.Common) is in the existing list
665
- [Fact]
666
- public async Task DependencyConflictsCanBeResolvedNewSingleTransitiveDependencyExisting()
741
+ [Theory]
742
+ [InlineData(true)]
743
+ [InlineData(false)]
744
+ public async Task DependencyConflictsCanBeResolvedNewSingleTransitiveDependencyExisting(bool useExistingSdks)
667
745
  {
668
746
  using var tempDirectory = new TemporaryDirectory();
669
747
  var projectPath = Path.Join(tempDirectory.DirectoryPath, "project.csproj");
@@ -693,7 +771,15 @@ public class MSBuildHelperTests : TestBase
693
771
  new Dependency("Microsoft.CodeAnalysis.Common", "4.10.0", DependencyType.PackageReference)
694
772
  };
695
773
 
696
- var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(tempDirectory.DirectoryPath, projectPath, "net8.0", dependencies, update, new TestLogger());
774
+ var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(
775
+ tempDirectory.DirectoryPath,
776
+ projectPath,
777
+ "net8.0",
778
+ dependencies,
779
+ update,
780
+ new ExperimentsManager() { InstallDotnetSdks = useExistingSdks },
781
+ new TestLogger()
782
+ );
697
783
  Assert.NotNull(resolvedDependencies);
698
784
  Assert.Equal(4, resolvedDependencies.Length);
699
785
  Assert.Equal("Microsoft.CodeAnalysis.Compilers", resolvedDependencies[0].Name);
@@ -709,8 +795,10 @@ public class MSBuildHelperTests : TestBase
709
795
  // A combination of the third and fourth test, to measure efficiency of updating separate families
710
796
  // Keeping a dependency that was not included in the original list (Newtonsoft.Json)
711
797
  // Not keeping a dependency that was not included in the original list (Microsoft.CodeAnalysis.Common)
712
- [Fact]
713
- public async Task DependencyConflictsCanBeResolvedNewSelectiveAdditionPackages()
798
+ [Theory]
799
+ [InlineData(true)]
800
+ [InlineData(false)]
801
+ public async Task DependencyConflictsCanBeResolvedNewSelectiveAdditionPackages(bool useExistingSdks)
714
802
  {
715
803
  using var tempDirectory = new TemporaryDirectory();
716
804
  var projectPath = Path.Join(tempDirectory.DirectoryPath, "project.csproj");
@@ -741,7 +829,15 @@ public class MSBuildHelperTests : TestBase
741
829
  new Dependency("Newtonsoft.Json", "13.0.1", DependencyType.Unknown)
742
830
  };
743
831
 
744
- var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(tempDirectory.DirectoryPath, projectPath, "net8.0", dependencies, update, new TestLogger());
832
+ var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(
833
+ tempDirectory.DirectoryPath,
834
+ projectPath,
835
+ "net8.0",
836
+ dependencies,
837
+ update,
838
+ new ExperimentsManager() { InstallDotnetSdks = useExistingSdks },
839
+ new TestLogger()
840
+ );
745
841
  Assert.NotNull(resolvedDependencies);
746
842
  Assert.Equal(5, resolvedDependencies.Length);
747
843
  Assert.Equal("Microsoft.CodeAnalysis.Compilers", resolvedDependencies[0].Name);
@@ -758,28 +854,45 @@ public class MSBuildHelperTests : TestBase
758
854
 
759
855
  // Two top level packages (Buildalyzer), (Microsoft.CodeAnalysis.CSharp.Scripting) that share a dependency (Microsoft.CodeAnalysis.Csharp)
760
856
  // Updating ONE of the top level packages, which updates the dependencies and their other "parents"
761
- // First family: Buildalyzer 7.0.1 requires Microsoft.CodeAnalysis.CSharp to be >= 4.0.0 and Microsoft.CodeAnalysis.Common to be 4.0.0 (@ 6.0.4, Microsoft.CodeAnalysis.Common isn't a dependency of buildalyzer)
762
- // Second family: Microsoft.CodeAnalysis.CSharp.Scripting 4.0.0 requires Microsoft.CodeAnalysis.CSharp 4.0.0 and Microsoft.CodeAnalysis.Common to be 4.0.0 (Specific version)
857
+ // First family: Buildalyzer 7.0.1 requires Microsoft.CodeAnalysis.CSharp to be = 4.0.1 and Microsoft.CodeAnalysis.Common to be 4.0.1 (@ 6.0.4, Microsoft.CodeAnalysis.Common isn't a dependency of buildalyzer)
858
+ // Second family: Microsoft.CodeAnalysis.CSharp.Scripting 4.0.1 requires Microsoft.CodeAnalysis.CSharp 4.0.1 and Microsoft.CodeAnalysis.Common to be 4.0.1 (Specific version)
763
859
  // Updating Buildalyzer to 7.0.1 will update its transitive dependency (Microsoft.CodeAnalysis.Common) and then its transitive dependency's "family"
764
860
  [Fact]
765
861
  public async Task DependencyConflictsCanBeResolvedNewSharingDependency()
766
862
  {
863
+ // arrange
767
864
  using var tempDirectory = new TemporaryDirectory();
768
865
  var projectPath = Path.Join(tempDirectory.DirectoryPath, "project.csproj");
769
866
  await File.WriteAllTextAsync(projectPath, """
770
867
  <Project Sdk="Microsoft.NET.Sdk">
771
- <PropertyGroup>
868
+ <PropertyGroup>
772
869
  <TargetFramework>net8.0</TargetFramework>
773
- </PropertyGroup>
774
- <ItemGroup>
870
+ </PropertyGroup>
871
+ <ItemGroup>
775
872
  <PackageReference Include="Buildalyzer" Version="6.0.4" />
776
873
  <PackageReference Include="Microsoft.CodeAnalysis.Csharp.Scripting" Version="3.10.0" />
777
874
  <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.10.0" />
778
875
  <PackageReference Include="Microsoft.CodeAnalysis.Common" Version="3.10.0" />
779
- </ItemGroup>
876
+ </ItemGroup>
780
877
  </Project>
781
878
  """);
782
879
 
880
+ var testPackages = new MockNuGetPackage[]
881
+ {
882
+ MockNuGetPackage.CreateSimplePackage("Buildalyzer", "6.0.4", "net8.0", [(null, [("Microsoft.CodeAnalysis.CSharp", "[3.10.0]")])]),
883
+ MockNuGetPackage.CreateSimplePackage("Buildalyzer", "7.0.1", "net8.0", [(null, [("Microsoft.CodeAnalysis.CSharp", "[4.0.1]")])]),
884
+
885
+ MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.CSharp.Scripting", "3.10.0", "net8.0", [(null, [("Microsoft.CodeAnalysis.CSharp", "[3.10.0]")])]),
886
+ MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.CSharp.Scripting", "4.0.1", "net8.0", [(null, [("Microsoft.CodeAnalysis.CSharp", "[4.0.1]")])]),
887
+
888
+ MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.CSharp", "3.10.0", "net8.0", [(null, [("Microsoft.CodeAnalysis.Common", "[3.10.0]")])]),
889
+ MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.CSharp", "4.0.1", "net8.0", [(null, [("Microsoft.CodeAnalysis.Common", "[4.0.1]")])]),
890
+
891
+ MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.Common", "3.10.0", "net8.0"),
892
+ MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.Common", "4.0.1", "net8.0"),
893
+ };
894
+ await UpdateWorkerTestBase.MockNuGetPackagesInDirectory(testPackages, tempDirectory.DirectoryPath);
895
+
783
896
  var dependencies = new[]
784
897
  {
785
898
  new Dependency("Buildalyzer", "6.0.4", DependencyType.PackageReference),
@@ -792,24 +905,37 @@ public class MSBuildHelperTests : TestBase
792
905
  new Dependency("Buildalyzer", "7.0.1", DependencyType.PackageReference),
793
906
  };
794
907
 
795
- var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(tempDirectory.DirectoryPath, projectPath, "net8.0", dependencies, update, new TestLogger());
908
+ // act
909
+ var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(
910
+ tempDirectory.DirectoryPath,
911
+ projectPath,
912
+ "net8.0",
913
+ dependencies,
914
+ update,
915
+ new ExperimentsManager(),
916
+ new TestLogger()
917
+ );
918
+
919
+ // assert
920
+ var expectedDependencies = new[]
921
+ {
922
+ "Buildalyzer/7.0.1",
923
+ "Microsoft.CodeAnalysis.CSharp.Scripting/4.0.1",
924
+ "Microsoft.CodeAnalysis.CSharp/4.0.1",
925
+ "Microsoft.CodeAnalysis.Common/4.0.1"
926
+ };
796
927
  Assert.NotNull(resolvedDependencies);
797
- Assert.Equal(4, resolvedDependencies.Length);
798
- Assert.Equal("Buildalyzer", resolvedDependencies[0].Name);
799
- Assert.Equal("7.0.1", resolvedDependencies[0].Version);
800
- Assert.Equal("Microsoft.CodeAnalysis.CSharp.Scripting", resolvedDependencies[1].Name);
801
- Assert.Equal("4.0.0", resolvedDependencies[1].Version);
802
- Assert.Equal("Microsoft.CodeAnalysis.CSharp", resolvedDependencies[2].Name);
803
- Assert.Equal("4.0.0", resolvedDependencies[2].Version);
804
- Assert.Equal("Microsoft.CodeAnalysis.Common", resolvedDependencies[3].Name);
805
- Assert.Equal("4.0.0", resolvedDependencies[3].Version);
928
+ var actualDependencies = resolvedDependencies.Select(d => $"{d.Name}/{d.Version}").ToArray();
929
+ AssertEx.Equal(expectedDependencies, actualDependencies);
806
930
  }
807
931
 
808
932
  // Updating two families at once to test efficiency
809
933
  // First family: Direct dependency (Microsoft.CodeAnalysis.Common) needs to be updated, which will then need to update in the existing list its dependency (System.Collections.Immutable) and "parent" (Microsoft.CodeAnalysis.Csharp.Scripting)
810
934
  // Second family: Updating the root package (Azure.Core) in the existing list will also need to update its dependency (Microsoft.Bcl.AsyncInterfaces)
811
- [Fact]
812
- public async Task DependencyConflictsCanBeResolvedNewUpdatingEntireFamily()
935
+ [Theory]
936
+ [InlineData(true)]
937
+ [InlineData(false)]
938
+ public async Task DependencyConflictsCanBeResolvedNewUpdatingEntireFamily(bool useExistingSdks)
813
939
  {
814
940
  using var tempDirectory = new TemporaryDirectory();
815
941
  var projectPath = Path.Join(tempDirectory.DirectoryPath, "project.csproj");
@@ -841,7 +967,15 @@ public class MSBuildHelperTests : TestBase
841
967
  new Dependency("Azure.Core", "1.22.0", DependencyType.PackageReference)
842
968
  };
843
969
 
844
- var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(tempDirectory.DirectoryPath, projectPath, "net8.0", dependencies, update, new TestLogger());
970
+ var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(
971
+ tempDirectory.DirectoryPath,
972
+ projectPath,
973
+ "net8.0",
974
+ dependencies,
975
+ update,
976
+ new ExperimentsManager() { InstallDotnetSdks = useExistingSdks },
977
+ new TestLogger()
978
+ );
845
979
  Assert.NotNull(resolvedDependencies);
846
980
  Assert.Equal(4, resolvedDependencies.Length);
847
981
  Assert.Equal("System.Collections.Immutable", resolvedDependencies[0].Name);
@@ -855,8 +989,10 @@ public class MSBuildHelperTests : TestBase
855
989
  }
856
990
 
857
991
  // Similar to the last test, except Microsoft.CodeAnalysis.Common is in the existing list
858
- [Fact]
859
- public async Task DependencyConflictsCanBeResolvedNewUpdatingTopLevelAndDependency()
992
+ [Theory]
993
+ [InlineData(true)]
994
+ [InlineData(false)]
995
+ public async Task DependencyConflictsCanBeResolvedNewUpdatingTopLevelAndDependency(bool useExistingSdks)
860
996
  {
861
997
  using var tempDirectory = new TemporaryDirectory();
862
998
  var projectPath = Path.Join(tempDirectory.DirectoryPath, "project.csproj");
@@ -890,7 +1026,15 @@ public class MSBuildHelperTests : TestBase
890
1026
  new Dependency("Azure.Core", "1.22.0", DependencyType.PackageReference)
891
1027
  };
892
1028
 
893
- var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(tempDirectory.DirectoryPath, projectPath, "net8.0", dependencies, update, new TestLogger());
1029
+ var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(
1030
+ tempDirectory.DirectoryPath,
1031
+ projectPath,
1032
+ "net8.0",
1033
+ dependencies,
1034
+ update,
1035
+ new ExperimentsManager() { InstallDotnetSdks = useExistingSdks },
1036
+ new TestLogger()
1037
+ );
894
1038
  Assert.NotNull(resolvedDependencies);
895
1039
  Assert.Equal(5, resolvedDependencies.Length);
896
1040
  Assert.Equal("System.Collections.Immutable", resolvedDependencies[0].Name);
@@ -908,8 +1052,10 @@ public class MSBuildHelperTests : TestBase
908
1052
  // Out of scope test: AutoMapper.Extensions.Microsoft.DependencyInjection's versions are not yet compatible
909
1053
  // To update root package (AutoMapper.Collection) to 10.0.0, its dependency (AutoMapper) needs to update to 13.0.0.
910
1054
  // However, there is no higher version of AutoMapper's other "parent" (AutoMapper.Extensions.Microsoft.DependencyInjection) that is compatible with the new version
911
- [Fact]
912
- public async Task DependencyConflictsCanBeResolvedNewOutOfScope()
1055
+ [Theory]
1056
+ [InlineData(true)]
1057
+ [InlineData(false)]
1058
+ public async Task DependencyConflictsCanBeResolvedNewOutOfScope(bool useExistingSdks)
913
1059
  {
914
1060
  using var tempDirectory = new TemporaryDirectory();
915
1061
  var projectPath = Path.Join(tempDirectory.DirectoryPath, "project.csproj");
@@ -937,7 +1083,15 @@ public class MSBuildHelperTests : TestBase
937
1083
  new Dependency("AutoMapper.Collection", "10.0.0", DependencyType.PackageReference)
938
1084
  };
939
1085
 
940
- var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(tempDirectory.DirectoryPath, projectPath, "net8.0", dependencies, update, new TestLogger());
1086
+ var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(
1087
+ tempDirectory.DirectoryPath,
1088
+ projectPath,
1089
+ "net8.0",
1090
+ dependencies,
1091
+ update,
1092
+ new ExperimentsManager() { InstallDotnetSdks = useExistingSdks },
1093
+ new TestLogger()
1094
+ );
941
1095
  Assert.NotNull(resolvedDependencies);
942
1096
  Assert.Equal(3, resolvedDependencies.Length);
943
1097
  Assert.Equal("AutoMapper.Extensions.Microsoft.DependencyInjection", resolvedDependencies[0].Name);
@@ -949,8 +1103,10 @@ public class MSBuildHelperTests : TestBase
949
1103
  }
950
1104
 
951
1105
  // Two dependencies (Microsoft.Extensions.Caching.Memory), (Microsoft.EntityFrameworkCore.Analyzers) used by the same parent (Microsoft.EntityFrameworkCore), updating one of the dependencies
952
- [Fact]
953
- public async Task DependencyConflictsCanBeResolvedNewTwoDependenciesShareSameParent()
1106
+ [Theory]
1107
+ [InlineData(true)]
1108
+ [InlineData(false)]
1109
+ public async Task DependencyConflictsCanBeResolvedNewTwoDependenciesShareSameParent(bool useExistingSdks)
954
1110
  {
955
1111
  using var tempDirectory = new TemporaryDirectory();
956
1112
  var projectPath = Path.Join(tempDirectory.DirectoryPath, "project.csproj");
@@ -976,7 +1132,15 @@ public class MSBuildHelperTests : TestBase
976
1132
  new Dependency("Microsoft.Extensions.Caching.Memory", "8.0.0", DependencyType.PackageReference)
977
1133
  };
978
1134
 
979
- var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(tempDirectory.DirectoryPath, projectPath, "net8.0", dependencies, update, new TestLogger());
1135
+ var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(
1136
+ tempDirectory.DirectoryPath,
1137
+ projectPath,
1138
+ "net8.0",
1139
+ dependencies,
1140
+ update,
1141
+ new ExperimentsManager() { InstallDotnetSdks = useExistingSdks },
1142
+ new TestLogger()
1143
+ );
980
1144
  Assert.NotNull(resolvedDependencies);
981
1145
  Assert.Equal(2, resolvedDependencies.Length);
982
1146
  Assert.Equal("Microsoft.EntityFrameworkCore", resolvedDependencies[0].Name);
@@ -987,8 +1151,10 @@ public class MSBuildHelperTests : TestBase
987
1151
 
988
1152
  // Updating referenced package
989
1153
  // 4 dependency chain to be updated. Since the package to be updated is in the existing list, do not update its parents since we want to change as little as possible
990
- [Fact]
991
- public async Task DependencyConflictsCanBeResolvedNewFamilyOfFourExisting()
1154
+ [Theory]
1155
+ [InlineData(true)]
1156
+ [InlineData(false)]
1157
+ public async Task DependencyConflictsCanBeResolvedNewFamilyOfFourExisting(bool useExistingSdks)
992
1158
  {
993
1159
  using var tempDirectory = new TemporaryDirectory();
994
1160
  var projectPath = Path.Join(tempDirectory.DirectoryPath, "project.csproj");
@@ -1018,7 +1184,15 @@ public class MSBuildHelperTests : TestBase
1018
1184
  new Dependency("Microsoft.EntityFrameworkCore.Analyzers", "8.0.0", DependencyType.PackageReference)
1019
1185
  };
1020
1186
 
1021
- var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(tempDirectory.DirectoryPath, projectPath, "net8.0", dependencies, update, new TestLogger());
1187
+ var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(
1188
+ tempDirectory.DirectoryPath,
1189
+ projectPath,
1190
+ "net8.0",
1191
+ dependencies,
1192
+ update,
1193
+ new ExperimentsManager() { InstallDotnetSdks = useExistingSdks },
1194
+ new TestLogger()
1195
+ );
1022
1196
  Assert.NotNull(resolvedDependencies);
1023
1197
  Assert.Equal(4, resolvedDependencies.Length);
1024
1198
  Assert.Equal("Microsoft.EntityFrameworkCore.Design", resolvedDependencies[0].Name);
@@ -1033,8 +1207,10 @@ public class MSBuildHelperTests : TestBase
1033
1207
 
1034
1208
  // Updating unreferenced package
1035
1209
  // 4 dependency chain to be updated, dependency to be updated is not in the existing list, so its family will all be updated
1036
- [Fact]
1037
- public async Task DependencyConflictsCanBeResolvedNewFamilyOfFourNotInExisting()
1210
+ [Theory]
1211
+ [InlineData(true)]
1212
+ [InlineData(false)]
1213
+ public async Task DependencyConflictsCanBeResolvedNewFamilyOfFourNotInExisting(bool useExistingSdks)
1038
1214
  {
1039
1215
  using var tempDirectory = new TemporaryDirectory();
1040
1216
  var projectPath = Path.Join(tempDirectory.DirectoryPath, "project.csproj");
@@ -1062,7 +1238,15 @@ public class MSBuildHelperTests : TestBase
1062
1238
  new Dependency("Microsoft.EntityFrameworkCore.Analyzers", "8.0.0", DependencyType.PackageReference)
1063
1239
  };
1064
1240
 
1065
- var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(tempDirectory.DirectoryPath, projectPath, "net8.0", dependencies, update, new TestLogger());
1241
+ var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(
1242
+ tempDirectory.DirectoryPath,
1243
+ projectPath,
1244
+ "net8.0",
1245
+ dependencies,
1246
+ update,
1247
+ new ExperimentsManager() { InstallDotnetSdks = useExistingSdks },
1248
+ new TestLogger()
1249
+ );
1066
1250
  Assert.NotNull(resolvedDependencies);
1067
1251
  Assert.Equal(3, resolvedDependencies.Length);
1068
1252
  Assert.Equal("Microsoft.EntityFrameworkCore.Design", resolvedDependencies[0].Name);
@@ -1075,8 +1259,10 @@ public class MSBuildHelperTests : TestBase
1075
1259
 
1076
1260
  // Updating a referenced transitive dependency
1077
1261
  // Updating a transtitive dependency (System.Collections.Immutable) to 8.0.0, which will update its "parent" (Microsoft.CodeAnalysis.CSharp) and its "grandparent" (Microsoft.CodeAnalysis.CSharp.Workspaces) to update
1078
- [Fact]
1079
- public async Task DependencyConflictsCanBeResolvedNewFamilyOfFourSpecificExisting()
1262
+ [Theory]
1263
+ [InlineData(true)]
1264
+ [InlineData(false)]
1265
+ public async Task DependencyConflictsCanBeResolvedNewFamilyOfFourSpecificExisting(bool useExistingSdks)
1080
1266
  {
1081
1267
  using var tempDirectory = new TemporaryDirectory();
1082
1268
  var projectPath = Path.Join(tempDirectory.DirectoryPath, "project.csproj");
@@ -1106,7 +1292,15 @@ public class MSBuildHelperTests : TestBase
1106
1292
  new Dependency("System.Collections.Immutable", "8.0.0", DependencyType.PackageReference),
1107
1293
  };
1108
1294
 
1109
- var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(tempDirectory.DirectoryPath, projectPath, "net8.0", dependencies, update, new TestLogger());
1295
+ var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(
1296
+ tempDirectory.DirectoryPath,
1297
+ projectPath,
1298
+ "net8.0",
1299
+ dependencies,
1300
+ update,
1301
+ new ExperimentsManager() { InstallDotnetSdks = useExistingSdks },
1302
+ new TestLogger()
1303
+ );
1110
1304
  Assert.NotNull(resolvedDependencies);
1111
1305
  Assert.Equal(4, resolvedDependencies.Length);
1112
1306
  Assert.Equal("System.Collections.Immutable", resolvedDependencies[0].Name);
@@ -1120,8 +1314,10 @@ public class MSBuildHelperTests : TestBase
1120
1314
  }
1121
1315
 
1122
1316
  // Similar to the last test, with the "grandchild" (System.Collections.Immutable) not in the existing list
1123
- [Fact]
1124
- public async Task DependencyConflictsCanBeResolvedNewFamilyOfFourSpecificNotInExisting()
1317
+ [Theory]
1318
+ [InlineData(true)]
1319
+ [InlineData(false)]
1320
+ public async Task DependencyConflictsCanBeResolvedNewFamilyOfFourSpecificNotInExisting(bool useExistingSdks)
1125
1321
  {
1126
1322
  using var tempDirectory = new TemporaryDirectory();
1127
1323
  var projectPath = Path.Join(tempDirectory.DirectoryPath, "project.csproj");
@@ -1150,7 +1346,15 @@ public class MSBuildHelperTests : TestBase
1150
1346
  new Dependency("System.Collections.Immutable", "8.0.0", DependencyType.PackageReference),
1151
1347
  };
1152
1348
 
1153
- var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(tempDirectory.DirectoryPath, projectPath, "net8.0", dependencies, update, new TestLogger());
1349
+ var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(
1350
+ tempDirectory.DirectoryPath,
1351
+ projectPath,
1352
+ "net8.0",
1353
+ dependencies,
1354
+ update,
1355
+ new ExperimentsManager() { InstallDotnetSdks = useExistingSdks },
1356
+ new TestLogger()
1357
+ );
1154
1358
  Assert.NotNull(resolvedDependencies);
1155
1359
  Assert.Equal(3, resolvedDependencies.Length);
1156
1360
  Assert.Equal("Microsoft.CodeAnalysis.CSharp.Workspaces", resolvedDependencies[0].Name);