dependabot-nuget 0.288.0 → 0.290.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. data/helpers/lib/NuGetUpdater/Directory.Packages.props +19 -17
  3. data/helpers/lib/NuGetUpdater/NuGetProjects/NuGet.Packaging/NuGet.Packaging.csproj +0 -1
  4. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/AnalyzeCommand.cs +7 -3
  5. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/RunCommand.cs +1 -1
  6. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Analyze.cs +29 -2
  7. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Discover.cs +25 -4
  8. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Run.cs +0 -6
  9. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/AnalyzeWorker.cs +33 -16
  10. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/CompatabilityChecker.cs +25 -10
  11. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/NuGetContext.cs +0 -13
  12. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/RequirementArrayConverter.cs +39 -0
  13. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/VersionFinder.cs +1 -1
  14. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Clone/ShellGitCommandHandler.cs +1 -1
  15. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DiscoveryWorker.cs +60 -66
  16. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DotNetToolsJsonDiscovery.cs +2 -2
  17. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/GlobalJsonDiscovery.cs +2 -2
  18. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/PackagesConfigDiscovery.cs +11 -3
  19. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/PackagesConfigDiscoveryResult.cs +1 -0
  20. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/ProjectDiscoveryResult.cs +2 -4
  21. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/SdkProjectDiscovery.cs +54 -11
  22. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/WorkspaceDiscoveryResult.cs +0 -1
  23. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/ExperimentsManager.cs +1 -2
  24. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/JsonBuildFile.cs +1 -1
  25. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/FrameworkChecker/CompatabilityChecker.cs +2 -2
  26. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/Advisory.cs +13 -0
  27. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/AllowedUpdate.cs +18 -1
  28. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/CommitOptions.cs +8 -0
  29. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/Condition.cs +19 -0
  30. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/DependencyGroup.cs +8 -0
  31. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/GroupPullRequest.cs +9 -0
  32. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/Job.cs +13 -10
  33. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/PullRequest.cs +11 -0
  34. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/RequirementsUpdateStrategy.cs +15 -0
  35. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/RunWorker.cs +67 -58
  36. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/VersionConverter.cs +19 -0
  37. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/BindingRedirectManager.cs +15 -44
  38. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/DotNetToolsJsonUpdater.cs +4 -4
  39. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/GlobalJsonUpdater.cs +5 -5
  40. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/LockFileUpdater.cs +2 -10
  41. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/PackageReferenceUpdater.cs +38 -33
  42. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/PackagesConfigUpdater.cs +25 -23
  43. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/UpdaterWorker.cs +16 -12
  44. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/ConsoleLogger.cs +1 -1
  45. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/DependencyConflictResolver.cs +19 -19
  46. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/ILogger.cs +11 -1
  47. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/JsonHelper.cs +2 -0
  48. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/MSBuildHelper.cs +18 -17
  49. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/NuGetHelper.cs +1 -17
  50. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/PathHelper.cs +17 -9
  51. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/ProjectHelper.cs +96 -0
  52. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Analyze/AnalyzeWorkerTestBase.cs +5 -2
  53. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Analyze/AnalyzeWorkerTests.cs +87 -5
  54. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTestBase.cs +2 -5
  55. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.DotNetToolsJson.cs +45 -1
  56. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.GlobalJson.cs +35 -1
  57. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.PackagesConfig.cs +16 -0
  58. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.Proj.cs +6 -0
  59. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.Project.cs +143 -36
  60. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.cs +184 -48
  61. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/ExpectedDiscoveryResults.cs +5 -5
  62. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/SdkProjectDiscoveryTests.cs +32 -10
  63. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/MiscellaneousTests.cs +85 -0
  64. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/RunWorkerTests.cs +402 -102
  65. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/SerializationTests.cs +342 -2
  66. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/UpdatedDependencyListTests.cs +60 -2
  67. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/TemporaryDirectory.cs +18 -7
  68. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/TestLogger.cs +1 -1
  69. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/BindingRedirectsTests.cs +1 -1
  70. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/PackagesConfigUpdaterTests.cs +24 -0
  71. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTestBase.cs +4 -14
  72. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.DotNetTools.cs +84 -0
  73. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.GlobalJson.cs +66 -0
  74. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackageReference.cs +95 -0
  75. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackagesConfig.cs +1 -7
  76. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/AssertEx.cs +1 -1
  77. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/LinuxOnlyAttribute.cs +12 -0
  78. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/MSBuildHelperTests.cs +558 -711
  79. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/PathHelperTests.cs +47 -2
  80. data/lib/dependabot/nuget/analysis/analysis_json_reader.rb +4 -2
  81. data/lib/dependabot/nuget/analysis/dependency_analysis.rb +3 -3
  82. data/lib/dependabot/nuget/discovery/dependency_details.rb +10 -3
  83. data/lib/dependabot/nuget/discovery/dependency_file_discovery.rb +8 -12
  84. data/lib/dependabot/nuget/discovery/discovery_json_reader.rb +214 -29
  85. data/lib/dependabot/nuget/discovery/project_discovery.rb +41 -8
  86. data/lib/dependabot/nuget/discovery/workspace_discovery.rb +14 -19
  87. data/lib/dependabot/nuget/file_fetcher.rb +11 -393
  88. data/lib/dependabot/nuget/file_parser.rb +23 -61
  89. data/lib/dependabot/nuget/file_updater.rb +28 -23
  90. data/lib/dependabot/nuget/native_helpers.rb +14 -5
  91. data/lib/dependabot/nuget/update_checker/requirements_updater.rb +23 -27
  92. data/lib/dependabot/nuget/update_checker.rb +116 -190
  93. metadata +20 -32
  94. data/helpers/lib/NuGetUpdater/NuGetProjects/Directory.Packages.props +0 -29
  95. data/lib/dependabot/nuget/discovery/directory_packages_props_discovery.rb +0 -43
  96. data/lib/dependabot/nuget/file_fetcher/import_paths_finder.rb +0 -73
  97. data/lib/dependabot/nuget/file_fetcher/sln_project_paths_finder.rb +0 -60
  98. data/lib/dependabot/nuget/http_response_helpers.rb +0 -19
  99. data/lib/dependabot/nuget/native_discovery/native_dependency_details.rb +0 -102
  100. data/lib/dependabot/nuget/native_discovery/native_dependency_file_discovery.rb +0 -129
  101. data/lib/dependabot/nuget/native_discovery/native_discovery_json_reader.rb +0 -171
  102. data/lib/dependabot/nuget/native_discovery/native_evaluation_details.rb +0 -63
  103. data/lib/dependabot/nuget/native_discovery/native_project_discovery.rb +0 -82
  104. data/lib/dependabot/nuget/native_discovery/native_property_details.rb +0 -43
  105. data/lib/dependabot/nuget/native_discovery/native_workspace_discovery.rb +0 -68
  106. data/lib/dependabot/nuget/native_update_checker/native_requirements_updater.rb +0 -105
  107. data/lib/dependabot/nuget/native_update_checker/native_update_checker.rb +0 -201
  108. data/lib/dependabot/nuget/nuget_client.rb +0 -223
  109. data/lib/dependabot/nuget/update_checker/compatibility_checker.rb +0 -116
  110. data/lib/dependabot/nuget/update_checker/dependency_finder.rb +0 -297
  111. data/lib/dependabot/nuget/update_checker/nupkg_fetcher.rb +0 -221
  112. data/lib/dependabot/nuget/update_checker/nuspec_fetcher.rb +0 -110
  113. data/lib/dependabot/nuget/update_checker/property_updater.rb +0 -196
  114. data/lib/dependabot/nuget/update_checker/repository_finder.rb +0 -466
  115. data/lib/dependabot/nuget/update_checker/tfm_comparer.rb +0 -34
  116. data/lib/dependabot/nuget/update_checker/tfm_finder.rb +0 -30
  117. data/lib/dependabot/nuget/update_checker/version_finder.rb +0 -449
@@ -172,7 +172,8 @@ public class MSBuildHelperTests : TestBase
172
172
  temp.DirectoryPath,
173
173
  temp.DirectoryPath,
174
174
  "netstandard2.0",
175
- [new Dependency("Package.A", "1.0.0", DependencyType.Unknown)]
175
+ [new Dependency("Package.A", "1.0.0", DependencyType.Unknown)],
176
+ new TestLogger()
176
177
  );
177
178
  AssertEx.Equal(expectedDependencies, actualDependencies);
178
179
  }
@@ -300,7 +301,7 @@ public class MSBuildHelperTests : TestBase
300
301
  new Dependency("Package.2A", "1.0.0", DependencyType.Unknown),
301
302
  new Dependency("Package.2R", "18.0.0", DependencyType.Unknown),
302
303
  };
303
- var actualDependencies = await MSBuildHelper.GetAllPackageDependenciesAsync(temp.DirectoryPath, temp.DirectoryPath, "net8.0", packages);
304
+ var actualDependencies = await MSBuildHelper.GetAllPackageDependenciesAsync(temp.DirectoryPath, temp.DirectoryPath, "net8.0", packages, new TestLogger());
304
305
  for (int i = 0; i < actualDependencies.Length; i++)
305
306
  {
306
307
  var ad = actualDependencies[i];
@@ -334,111 +335,77 @@ public class MSBuildHelperTests : TestBase
334
335
  new Dependency("Package.B", "2.0.0", DependencyType.Unknown, TargetFrameworks: ["net8.0"]),
335
336
  new Dependency("Package.C", "3.0.0", DependencyType.Unknown, IsUpdate: true)
336
337
  };
337
- var actualDependencies = await MSBuildHelper.GetAllPackageDependenciesAsync(temp.DirectoryPath, temp.DirectoryPath, "net8.0", packages);
338
+ var actualDependencies = await MSBuildHelper.GetAllPackageDependenciesAsync(temp.DirectoryPath, temp.DirectoryPath, "net8.0", packages, new TestLogger());
338
339
  AssertEx.Equal(expectedDependencies, actualDependencies);
339
340
  }
340
341
 
341
342
  [Fact]
342
343
  public async Task GetAllPackageDependencies_NugetConfigInvalid_DoesNotThrow()
343
344
  {
344
- var nugetPackagesDirectory = Environment.GetEnvironmentVariable("NUGET_PACKAGES");
345
- var nugetHttpCacheDirectory = Environment.GetEnvironmentVariable("NUGET_HTTP_CACHE_PATH");
346
-
347
- try
348
- {
349
- using var temp = new TemporaryDirectory();
350
-
351
- // It is important to have empty NuGet caches for this test, so override them with temp directories.
352
- var tempNuGetPackagesDirectory = Path.Combine(temp.DirectoryPath, ".nuget", "packages");
353
- Environment.SetEnvironmentVariable("NUGET_PACKAGES", tempNuGetPackagesDirectory);
354
- var tempNuGetHttpCacheDirectory = Path.Combine(temp.DirectoryPath, ".nuget", "v3-cache");
355
- Environment.SetEnvironmentVariable("NUGET_HTTP_CACHE_PATH", tempNuGetHttpCacheDirectory);
356
-
357
- // Write the NuGet.config with a missing "/>"
358
- await File.WriteAllTextAsync(
359
- Path.Combine(temp.DirectoryPath, "NuGet.Config"), """
360
- <?xml version="1.0" encoding="utf-8"?>
361
- <configuration>
362
- <packageSources>
363
- <clear />
364
- <add key="contoso" value="https://contoso.com/v3/index.json"
365
- </packageSources>
366
- </configuration>
367
- """);
345
+ using var temp = new TemporaryDirectory();
368
346
 
369
- // Asserting it didn't throw
370
- var actualDependencies = await MSBuildHelper.GetAllPackageDependenciesAsync(
371
- temp.DirectoryPath,
372
- temp.DirectoryPath,
373
- "net8.0",
374
- [new Dependency("Some.Package", "4.5.11", DependencyType.Unknown)]
375
- );
376
- }
377
- finally
378
- {
379
- // Restore the NuGet caches.
380
- Environment.SetEnvironmentVariable("NUGET_PACKAGES", nugetPackagesDirectory);
381
- Environment.SetEnvironmentVariable("NUGET_HTTP_CACHE_PATH", nugetHttpCacheDirectory);
382
- }
347
+ // Write the NuGet.config with a missing "/>"
348
+ await File.WriteAllTextAsync(
349
+ Path.Combine(temp.DirectoryPath, "NuGet.Config"), """
350
+ <?xml version="1.0" encoding="utf-8"?>
351
+ <configuration>
352
+ <packageSources>
353
+ <clear />
354
+ <add key="contoso" value="https://contoso.com/v3/index.json"
355
+ </packageSources>
356
+ </configuration>
357
+ """);
358
+
359
+ // Asserting it didn't throw
360
+ var actualDependencies = await MSBuildHelper.GetAllPackageDependenciesAsync(
361
+ temp.DirectoryPath,
362
+ temp.DirectoryPath,
363
+ "net8.0",
364
+ [new Dependency("Some.Package", "4.5.11", DependencyType.Unknown)],
365
+ new TestLogger()
366
+ );
383
367
  }
384
368
 
385
369
  [Fact]
386
370
  public async Task LocalPackageSourcesAreHonored()
387
371
  {
388
- var nugetPackagesDirectory = Environment.GetEnvironmentVariable("NUGET_PACKAGES");
389
- var nugetHttpCacheDirectory = Environment.GetEnvironmentVariable("NUGET_HTTP_CACHE_PATH");
372
+ using var temp = new TemporaryDirectory();
390
373
 
391
- try
392
- {
393
- using var temp = new TemporaryDirectory();
394
-
395
- // It is important to have empty NuGet caches for this test, so override them with temp directories.
396
- var tempNuGetPackagesDirectory = Path.Combine(temp.DirectoryPath, ".nuget", "packages");
397
- Environment.SetEnvironmentVariable("NUGET_PACKAGES", tempNuGetPackagesDirectory);
398
- var tempNuGetHttpCacheDirectory = Path.Combine(temp.DirectoryPath, ".nuget", "v3-cache");
399
- Environment.SetEnvironmentVariable("NUGET_HTTP_CACHE_PATH", tempNuGetHttpCacheDirectory);
400
-
401
- // create two local package sources with different packages available in each
402
- string localSource1 = Path.Combine(temp.DirectoryPath, "local", "source1");
403
- Directory.CreateDirectory(localSource1);
404
- string localSource2 = Path.Combine(temp.DirectoryPath, "local", "source2");
405
- Directory.CreateDirectory(localSource2);
406
-
407
- // `Package.A` will only live in `local\source1` and uses Windows-style directory separators and will have
408
- // a dependency on `Package.B` which is only available in `local/source2` and uses Unix-style directory
409
- // separators.
410
- MockNuGetPackage.CreateSimplePackage("Package.A", "1.0.0", "net8.0", [(null, [("Package.B", "2.0.0")])]).WriteToDirectory(localSource1);
411
- MockNuGetPackage.CreateSimplePackage("Package.B", "2.0.0", "net8.0").WriteToDirectory(localSource2);
412
- await File.WriteAllTextAsync(Path.Join(temp.DirectoryPath, "NuGet.Config"), """
413
- <configuration>
414
- <packageSources>
415
- <add key="localSource1" value="local\source1" />
416
- <add key="localSource2" value="local/source2" />
417
- </packageSources>
418
- </configuration>
419
- """);
374
+ // create two local package sources with different packages available in each
375
+ string localSource1 = Path.Combine(temp.DirectoryPath, "local", "source1");
376
+ Directory.CreateDirectory(localSource1);
377
+ string localSource2 = Path.Combine(temp.DirectoryPath, "local", "source2");
378
+ Directory.CreateDirectory(localSource2);
379
+
380
+ // `Package.A` will only live in `local\source1` and uses Windows-style directory separators and will have
381
+ // a dependency on `Package.B` which is only available in `local/source2` and uses Unix-style directory
382
+ // separators.
383
+ MockNuGetPackage.CreateSimplePackage("Package.A", "1.0.0", "net8.0", [(null, [("Package.B", "2.0.0")])]).WriteToDirectory(localSource1);
384
+ MockNuGetPackage.CreateSimplePackage("Package.B", "2.0.0", "net8.0").WriteToDirectory(localSource2);
385
+ await File.WriteAllTextAsync(Path.Join(temp.DirectoryPath, "NuGet.Config"), """
386
+ <configuration>
387
+ <packageSources>
388
+ <add key="localSource1" value="local\source1" />
389
+ <add key="localSource2" value="local/source2" />
390
+ </packageSources>
391
+ </configuration>
392
+ """);
420
393
 
421
- Dependency[] expectedDependencies =
422
- [
423
- new("Package.A", "1.0.0", DependencyType.Unknown, TargetFrameworks: ["net8.0"]),
424
- new("Package.B", "2.0.0", DependencyType.Unknown, TargetFrameworks: ["net8.0"], IsTransitive: true),
425
- ];
394
+ Dependency[] expectedDependencies =
395
+ [
396
+ new("Package.A", "1.0.0", DependencyType.Unknown, TargetFrameworks: ["net8.0"]),
397
+ new("Package.B", "2.0.0", DependencyType.Unknown, TargetFrameworks: ["net8.0"], IsTransitive: true),
398
+ ];
426
399
 
427
- Dependency[] actualDependencies = await MSBuildHelper.GetAllPackageDependenciesAsync(
428
- temp.DirectoryPath,
429
- temp.DirectoryPath,
430
- "net8.0",
431
- [new Dependency("Package.A", "1.0.0", DependencyType.Unknown)]
432
- );
400
+ Dependency[] actualDependencies = await MSBuildHelper.GetAllPackageDependenciesAsync(
401
+ temp.DirectoryPath,
402
+ temp.DirectoryPath,
403
+ "net8.0",
404
+ [new Dependency("Package.A", "1.0.0", DependencyType.Unknown)],
405
+ new TestLogger()
406
+ );
433
407
 
434
- AssertEx.Equal(expectedDependencies, actualDependencies);
435
- }
436
- finally
437
- {
438
- // Restore the NuGet caches.
439
- Environment.SetEnvironmentVariable("NUGET_PACKAGES", nugetPackagesDirectory);
440
- Environment.SetEnvironmentVariable("NUGET_HTTP_CACHE_PATH", nugetHttpCacheDirectory);
441
- }
408
+ AssertEx.Equal(expectedDependencies, actualDependencies);
442
409
  }
443
410
 
444
411
  [Fact]
@@ -541,91 +508,75 @@ public class MSBuildHelperTests : TestBase
541
508
  [Fact]
542
509
  public async Task DependencyConflictsCanBeResolvedNewUpdatingTopLevelPackage()
543
510
  {
544
- var repoRoot = Directory.CreateTempSubdirectory($"test_{nameof(DependencyConflictsCanBeResolvedNewUpdatingTopLevelPackage)}_");
511
+ using var tempDirectory = new TemporaryDirectory();
512
+ var projectPath = Path.Join(tempDirectory.DirectoryPath, "project.csproj");
513
+ await File.WriteAllTextAsync(projectPath, """
514
+ <Project Sdk="Microsoft.NET.Sdk">
515
+ <PropertyGroup>
516
+ <TargetFramework>net8.0</TargetFramework>
517
+ </PropertyGroup>
518
+ <ItemGroup>
519
+ <PackageReference Include="CS-Script.Core" Version="1.3.1" />
520
+ <PackageReference Include="Microsoft.CodeAnalysis.Common" Version="3.4.0" />
521
+ <PackageReference Include="Microsoft.CodeAnalysis.Scripting.Common" Version="3.4.0" />
522
+ </ItemGroup>
523
+ </Project>
524
+ """);
545
525
 
546
- try
526
+ var dependencies = new[]
547
527
  {
548
- var projectPath = Path.Join(repoRoot.FullName, "project.csproj");
549
- await File.WriteAllTextAsync(projectPath, """
550
- <Project Sdk="Microsoft.NET.Sdk">
551
- <PropertyGroup>
552
- <TargetFramework>net8.0</TargetFramework>
553
- </PropertyGroup>
554
- <ItemGroup>
555
- <PackageReference Include="CS-Script.Core" Version="1.3.1" />
556
- <PackageReference Include="Microsoft.CodeAnalysis.Common" Version="3.4.0" />
557
- <PackageReference Include="Microsoft.CodeAnalysis.Scripting.Common" Version="3.4.0" />
558
- </ItemGroup>
559
- </Project>
560
- """);
561
-
562
- var dependencies = new[]
563
- {
564
- // Add comment about root and dependencies
565
- new Dependency("CS-Script.Core", "1.3.1", DependencyType.PackageReference),
566
- new Dependency("Microsoft.CodeAnalysis.Common", "3.4.0", DependencyType.PackageReference),
567
- new Dependency("Microsoft.CodeAnalysis.Scripting.Common", "3.4.0", DependencyType.PackageReference),
568
- };
569
- var update = new[]
570
- {
571
- new Dependency("CS-Script.Core", "2.0.0", DependencyType.PackageReference),
572
- };
573
-
574
- var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(repoRoot.FullName, projectPath, "net8.0", dependencies, update, new TestLogger());
575
- Assert.NotNull(resolvedDependencies);
576
- Assert.Equal(3, resolvedDependencies.Length);
577
- Assert.Equal("CS-Script.Core", resolvedDependencies[0].Name);
578
- Assert.Equal("2.0.0", resolvedDependencies[0].Version);
579
- Assert.Equal("Microsoft.CodeAnalysis.Common", resolvedDependencies[1].Name);
580
- Assert.Equal("3.6.0", resolvedDependencies[1].Version);
581
- Assert.Equal("Microsoft.CodeAnalysis.Scripting.Common", resolvedDependencies[2].Name);
582
- Assert.Equal("3.6.0", resolvedDependencies[2].Version);
583
- }
584
- finally
528
+ // Add comment about root and dependencies
529
+ new Dependency("CS-Script.Core", "1.3.1", DependencyType.PackageReference),
530
+ new Dependency("Microsoft.CodeAnalysis.Common", "3.4.0", DependencyType.PackageReference),
531
+ new Dependency("Microsoft.CodeAnalysis.Scripting.Common", "3.4.0", DependencyType.PackageReference),
532
+ };
533
+ var update = new[]
585
534
  {
586
- repoRoot.Delete(recursive: true);
587
- }
535
+ new Dependency("CS-Script.Core", "2.0.0", DependencyType.PackageReference),
536
+ };
537
+
538
+ var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(tempDirectory.DirectoryPath, projectPath, "net8.0", dependencies, update, new TestLogger());
539
+ Assert.NotNull(resolvedDependencies);
540
+ Assert.Equal(3, resolvedDependencies.Length);
541
+ Assert.Equal("CS-Script.Core", resolvedDependencies[0].Name);
542
+ Assert.Equal("2.0.0", resolvedDependencies[0].Version);
543
+ Assert.Equal("Microsoft.CodeAnalysis.Common", resolvedDependencies[1].Name);
544
+ Assert.Equal("3.6.0", resolvedDependencies[1].Version);
545
+ Assert.Equal("Microsoft.CodeAnalysis.Scripting.Common", resolvedDependencies[2].Name);
546
+ Assert.Equal("3.6.0", resolvedDependencies[2].Version);
588
547
  }
589
548
 
590
549
  // 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
591
550
  [Fact]
592
551
  public async Task DependencyConflictsCanBeResolvedNewUpdatingNonExistingDependency()
593
552
  {
594
- var repoRoot = Directory.CreateTempSubdirectory($"test_{nameof(DependencyConflictsCanBeResolvedNewUpdatingNonExistingDependency)}_");
553
+ using var tempDirectory = new TemporaryDirectory();
554
+ var projectPath = Path.Join(tempDirectory.DirectoryPath, "project.csproj");
555
+ await File.WriteAllTextAsync(projectPath, """
556
+ <Project Sdk="Microsoft.NET.Sdk">
557
+ <PropertyGroup>
558
+ <TargetFramework>net8.0</TargetFramework>
559
+ </PropertyGroup>
560
+ <ItemGroup>
561
+ <PackageReference Include="Azure.Core" Version="1.21.0" />
562
+ </ItemGroup>
563
+ </Project>
564
+ """);
595
565
 
596
- try
566
+ var dependencies = new[]
597
567
  {
598
- var projectPath = Path.Join(repoRoot.FullName, "project.csproj");
599
- await File.WriteAllTextAsync(projectPath, """
600
- <Project Sdk="Microsoft.NET.Sdk">
601
- <PropertyGroup>
602
- <TargetFramework>net8.0</TargetFramework>
603
- </PropertyGroup>
604
- <ItemGroup>
605
- <PackageReference Include="Azure.Core" Version="1.21.0" />
606
- </ItemGroup>
607
- </Project>
608
- """);
609
-
610
- var dependencies = new[]
611
- {
612
- new Dependency("Azure.Core", "1.21.0", DependencyType.PackageReference)
613
- };
614
- var update = new[]
615
- {
616
- new Dependency("Microsoft.Bcl.AsyncInterfaces", "1.1.1", DependencyType.Unknown)
617
- };
618
-
619
- var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(repoRoot.FullName, projectPath, "net8.0", dependencies, update, new TestLogger());
620
- Assert.NotNull(resolvedDependencies);
621
- Assert.Single(resolvedDependencies);
622
- Assert.Equal("Azure.Core", resolvedDependencies[0].Name);
623
- Assert.Equal("1.22.0", resolvedDependencies[0].Version);
624
- }
625
- finally
568
+ new Dependency("Azure.Core", "1.21.0", DependencyType.PackageReference)
569
+ };
570
+ var update = new[]
626
571
  {
627
- repoRoot.Delete(recursive: true);
628
- }
572
+ new Dependency("Microsoft.Bcl.AsyncInterfaces", "1.1.1", DependencyType.Unknown)
573
+ };
574
+
575
+ var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(tempDirectory.DirectoryPath, projectPath, "net8.0", dependencies, update, new TestLogger());
576
+ Assert.NotNull(resolvedDependencies);
577
+ Assert.Single(resolvedDependencies);
578
+ Assert.Equal("Azure.Core", resolvedDependencies[0].Name);
579
+ Assert.Equal("1.22.0", resolvedDependencies[0].Version);
629
580
  }
630
581
 
631
582
  // Adding a reference
@@ -634,43 +585,35 @@ public class MSBuildHelperTests : TestBase
634
585
  [Fact]
635
586
  public async Task DependencyConflictsCanBeResolvedNewUpdatingNonExistentDependencyAndKeepingReference()
636
587
  {
637
- var repoRoot = Directory.CreateTempSubdirectory($"test_{nameof(DependencyConflictsCanBeResolvedNewUpdatingNonExistentDependencyAndKeepingReference)}_");
588
+ using var tempDirectory = new TemporaryDirectory();
589
+ var projectPath = Path.Join(tempDirectory.DirectoryPath, "project.csproj");
590
+ await File.WriteAllTextAsync(projectPath, """
591
+ <Project Sdk="Microsoft.NET.Sdk">
592
+ <PropertyGroup>
593
+ <TargetFramework>net8.0</TargetFramework>
594
+ </PropertyGroup>
595
+ <ItemGroup>
596
+ <PackageReference Include="Newtonsoft.Json.Bson" Version="1.0.2" />
597
+ </ItemGroup>
598
+ </Project>
599
+ """);
638
600
 
639
- try
601
+ var dependencies = new[]
640
602
  {
641
- var projectPath = Path.Join(repoRoot.FullName, "project.csproj");
642
- await File.WriteAllTextAsync(projectPath, """
643
- <Project Sdk="Microsoft.NET.Sdk">
644
- <PropertyGroup>
645
- <TargetFramework>net8.0</TargetFramework>
646
- </PropertyGroup>
647
- <ItemGroup>
648
- <PackageReference Include="Newtonsoft.Json.Bson" Version="1.0.2" />
649
- </ItemGroup>
650
- </Project>
651
- """);
652
-
653
- var dependencies = new[]
654
- {
655
- new Dependency("Newtonsoft.Json.Bson", "1.0.2", DependencyType.PackageReference)
656
- };
657
- var update = new[]
658
- {
659
- new Dependency("Newtonsoft.Json", "13.0.1", DependencyType.Unknown)
660
- };
661
-
662
- var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(repoRoot.FullName, projectPath, "net8.0", dependencies, update, new TestLogger());
663
- Assert.NotNull(resolvedDependencies);
664
- Assert.Equal(2, resolvedDependencies.Length);
665
- Assert.Equal("Newtonsoft.Json.Bson", resolvedDependencies[0].Name);
666
- Assert.Equal("1.0.2", resolvedDependencies[0].Version);
667
- Assert.Equal("Newtonsoft.Json", resolvedDependencies[1].Name);
668
- Assert.Equal("13.0.1", resolvedDependencies[1].Version);
669
- }
670
- finally
603
+ new Dependency("Newtonsoft.Json.Bson", "1.0.2", DependencyType.PackageReference)
604
+ };
605
+ var update = new[]
671
606
  {
672
- repoRoot.Delete(recursive: true);
673
- }
607
+ new Dependency("Newtonsoft.Json", "13.0.1", DependencyType.Unknown)
608
+ };
609
+
610
+ var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(tempDirectory.DirectoryPath, projectPath, "net8.0", dependencies, update, new TestLogger());
611
+ Assert.NotNull(resolvedDependencies);
612
+ Assert.Equal(2, resolvedDependencies.Length);
613
+ Assert.Equal("Newtonsoft.Json.Bson", resolvedDependencies[0].Name);
614
+ Assert.Equal("1.0.2", resolvedDependencies[0].Version);
615
+ Assert.Equal("Newtonsoft.Json", resolvedDependencies[1].Name);
616
+ Assert.Equal("13.0.1", resolvedDependencies[1].Version);
674
617
  }
675
618
 
676
619
  // Updating unreferenced dependency
@@ -680,49 +623,41 @@ public class MSBuildHelperTests : TestBase
680
623
  [Fact]
681
624
  public async Task DependencyConflictsCanBeResolvedNewTransitiveDependencyNotExisting()
682
625
  {
683
- var repoRoot = Directory.CreateTempSubdirectory($"test_{nameof(DependencyConflictsCanBeResolvedNewTransitiveDependencyNotExisting)}_");
626
+ using var tempDirectory = new TemporaryDirectory();
627
+ var projectPath = Path.Join(tempDirectory.DirectoryPath, "project.csproj");
628
+ await File.WriteAllTextAsync(projectPath, """
629
+ <Project Sdk="Microsoft.NET.Sdk">
630
+ <PropertyGroup>
631
+ <TargetFramework>net8.0</TargetFramework>
632
+ </PropertyGroup>
633
+ <ItemGroup>
634
+ <PackageReference Include="Microsoft.CodeAnalysis.Compilers" Version="4.9.2" />
635
+ <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.9.2" />
636
+ <PackageReference Include="Microsoft.CodeAnalysis.VisualBasic" Version="4.9.2" />
637
+ </ItemGroup>
638
+ </Project>
639
+ """);
684
640
 
685
- try
641
+ var dependencies = new[]
686
642
  {
687
- var projectPath = Path.Join(repoRoot.FullName, "project.csproj");
688
- await File.WriteAllTextAsync(projectPath, """
689
- <Project Sdk="Microsoft.NET.Sdk">
690
- <PropertyGroup>
691
- <TargetFramework>net8.0</TargetFramework>
692
- </PropertyGroup>
693
- <ItemGroup>
694
- <PackageReference Include="Microsoft.CodeAnalysis.Compilers" Version="4.9.2" />
695
- <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.9.2" />
696
- <PackageReference Include="Microsoft.CodeAnalysis.VisualBasic" Version="4.9.2" />
697
- </ItemGroup>
698
- </Project>
699
- """);
700
-
701
- var dependencies = new[]
702
- {
703
- new Dependency("Microsoft.CodeAnalysis.Compilers", "4.9.2", DependencyType.PackageReference),
704
- new Dependency("Microsoft.CodeAnalysis.CSharp", "4.9.2", DependencyType.PackageReference),
705
- new Dependency("Microsoft.CodeAnalysis.VisualBasic", "4.9.2", DependencyType.PackageReference)
706
- };
707
- var update = new[]
708
- {
709
- new Dependency("Microsoft.CodeAnalysis.Common", "4.10.0", DependencyType.PackageReference)
710
- };
711
-
712
- var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(repoRoot.FullName, projectPath, "net8.0", dependencies, update, new TestLogger());
713
- Assert.NotNull(resolvedDependencies);
714
- Assert.Equal(3, resolvedDependencies.Length);
715
- Assert.Equal("Microsoft.CodeAnalysis.Compilers", resolvedDependencies[0].Name);
716
- Assert.Equal("4.10.0", resolvedDependencies[0].Version);
717
- Assert.Equal("Microsoft.CodeAnalysis.CSharp", resolvedDependencies[1].Name);
718
- Assert.Equal("4.10.0", resolvedDependencies[1].Version);
719
- Assert.Equal("Microsoft.CodeAnalysis.VisualBasic", resolvedDependencies[2].Name);
720
- Assert.Equal("4.10.0", resolvedDependencies[2].Version);
721
- }
722
- finally
643
+ new Dependency("Microsoft.CodeAnalysis.Compilers", "4.9.2", DependencyType.PackageReference),
644
+ new Dependency("Microsoft.CodeAnalysis.CSharp", "4.9.2", DependencyType.PackageReference),
645
+ new Dependency("Microsoft.CodeAnalysis.VisualBasic", "4.9.2", DependencyType.PackageReference)
646
+ };
647
+ var update = new[]
723
648
  {
724
- repoRoot.Delete(recursive: true);
725
- }
649
+ new Dependency("Microsoft.CodeAnalysis.Common", "4.10.0", DependencyType.PackageReference)
650
+ };
651
+
652
+ var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(tempDirectory.DirectoryPath, projectPath, "net8.0", dependencies, update, new TestLogger());
653
+ Assert.NotNull(resolvedDependencies);
654
+ Assert.Equal(3, resolvedDependencies.Length);
655
+ Assert.Equal("Microsoft.CodeAnalysis.Compilers", resolvedDependencies[0].Name);
656
+ Assert.Equal("4.10.0", resolvedDependencies[0].Version);
657
+ Assert.Equal("Microsoft.CodeAnalysis.CSharp", resolvedDependencies[1].Name);
658
+ Assert.Equal("4.10.0", resolvedDependencies[1].Version);
659
+ Assert.Equal("Microsoft.CodeAnalysis.VisualBasic", resolvedDependencies[2].Name);
660
+ Assert.Equal("4.10.0", resolvedDependencies[2].Version);
726
661
  }
727
662
 
728
663
  // Updating referenced dependency
@@ -730,53 +665,45 @@ public class MSBuildHelperTests : TestBase
730
665
  [Fact]
731
666
  public async Task DependencyConflictsCanBeResolvedNewSingleTransitiveDependencyExisting()
732
667
  {
733
- var repoRoot = Directory.CreateTempSubdirectory($"test_{nameof(DependencyConflictsCanBeResolvedNewSingleTransitiveDependencyExisting)}_");
668
+ using var tempDirectory = new TemporaryDirectory();
669
+ var projectPath = Path.Join(tempDirectory.DirectoryPath, "project.csproj");
670
+ await File.WriteAllTextAsync(projectPath, """
671
+ <Project Sdk="Microsoft.NET.Sdk">
672
+ <PropertyGroup>
673
+ <TargetFramework>net8.0</TargetFramework>
674
+ </PropertyGroup>
675
+ <ItemGroup>
676
+ <PackageReference Include="Microsoft.CodeAnalysis.Compilers" Version="4.9.2" />
677
+ <PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.9.2" />
678
+ <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.9.2" />
679
+ <PackageReference Include="Microsoft.CodeAnalysis.VisualBasic" Version="4.9.2" />
680
+ </ItemGroup>
681
+ </Project>
682
+ """);
734
683
 
735
- try
684
+ var dependencies = new[]
736
685
  {
737
- var projectPath = Path.Join(repoRoot.FullName, "project.csproj");
738
- await File.WriteAllTextAsync(projectPath, """
739
- <Project Sdk="Microsoft.NET.Sdk">
740
- <PropertyGroup>
741
- <TargetFramework>net8.0</TargetFramework>
742
- </PropertyGroup>
743
- <ItemGroup>
744
- <PackageReference Include="Microsoft.CodeAnalysis.Compilers" Version="4.9.2" />
745
- <PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.9.2" />
746
- <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.9.2" />
747
- <PackageReference Include="Microsoft.CodeAnalysis.VisualBasic" Version="4.9.2" />
748
- </ItemGroup>
749
- </Project>
750
- """);
751
-
752
- var dependencies = new[]
753
- {
754
- new Dependency("Microsoft.CodeAnalysis.Compilers", "4.9.2", DependencyType.PackageReference),
755
- new Dependency("Microsoft.CodeAnalysis.Common", "4.9.2", DependencyType.PackageReference),
756
- new Dependency("Microsoft.CodeAnalysis.CSharp", "4.9.2", DependencyType.PackageReference),
757
- new Dependency("Microsoft.CodeAnalysis.VisualBasic", "4.9.2", DependencyType.PackageReference)
758
- };
759
- var update = new[]
760
- {
761
- new Dependency("Microsoft.CodeAnalysis.Common", "4.10.0", DependencyType.PackageReference)
762
- };
763
-
764
- var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(repoRoot.FullName, projectPath, "net8.0", dependencies, update, new TestLogger());
765
- Assert.NotNull(resolvedDependencies);
766
- Assert.Equal(4, resolvedDependencies.Length);
767
- Assert.Equal("Microsoft.CodeAnalysis.Compilers", resolvedDependencies[0].Name);
768
- Assert.Equal("4.10.0", resolvedDependencies[0].Version);
769
- Assert.Equal("Microsoft.CodeAnalysis.Common", resolvedDependencies[1].Name);
770
- Assert.Equal("4.10.0", resolvedDependencies[1].Version);
771
- Assert.Equal("Microsoft.CodeAnalysis.CSharp", resolvedDependencies[2].Name);
772
- Assert.Equal("4.10.0", resolvedDependencies[2].Version);
773
- Assert.Equal("Microsoft.CodeAnalysis.VisualBasic", resolvedDependencies[3].Name);
774
- Assert.Equal("4.10.0", resolvedDependencies[3].Version);
775
- }
776
- finally
686
+ new Dependency("Microsoft.CodeAnalysis.Compilers", "4.9.2", DependencyType.PackageReference),
687
+ new Dependency("Microsoft.CodeAnalysis.Common", "4.9.2", DependencyType.PackageReference),
688
+ new Dependency("Microsoft.CodeAnalysis.CSharp", "4.9.2", DependencyType.PackageReference),
689
+ new Dependency("Microsoft.CodeAnalysis.VisualBasic", "4.9.2", DependencyType.PackageReference)
690
+ };
691
+ var update = new[]
777
692
  {
778
- repoRoot.Delete(recursive: true);
779
- }
693
+ new Dependency("Microsoft.CodeAnalysis.Common", "4.10.0", DependencyType.PackageReference)
694
+ };
695
+
696
+ var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(tempDirectory.DirectoryPath, projectPath, "net8.0", dependencies, update, new TestLogger());
697
+ Assert.NotNull(resolvedDependencies);
698
+ Assert.Equal(4, resolvedDependencies.Length);
699
+ Assert.Equal("Microsoft.CodeAnalysis.Compilers", resolvedDependencies[0].Name);
700
+ Assert.Equal("4.10.0", resolvedDependencies[0].Version);
701
+ Assert.Equal("Microsoft.CodeAnalysis.Common", resolvedDependencies[1].Name);
702
+ Assert.Equal("4.10.0", resolvedDependencies[1].Version);
703
+ Assert.Equal("Microsoft.CodeAnalysis.CSharp", resolvedDependencies[2].Name);
704
+ Assert.Equal("4.10.0", resolvedDependencies[2].Version);
705
+ Assert.Equal("Microsoft.CodeAnalysis.VisualBasic", resolvedDependencies[3].Name);
706
+ Assert.Equal("4.10.0", resolvedDependencies[3].Version);
780
707
  }
781
708
 
782
709
  // A combination of the third and fourth test, to measure efficiency of updating separate families
@@ -785,56 +712,48 @@ public class MSBuildHelperTests : TestBase
785
712
  [Fact]
786
713
  public async Task DependencyConflictsCanBeResolvedNewSelectiveAdditionPackages()
787
714
  {
788
- var repoRoot = Directory.CreateTempSubdirectory($"test_{nameof(DependencyConflictsCanBeResolvedNewSelectiveAdditionPackages)}_");
715
+ using var tempDirectory = new TemporaryDirectory();
716
+ var projectPath = Path.Join(tempDirectory.DirectoryPath, "project.csproj");
717
+ await File.WriteAllTextAsync(projectPath, """
718
+ <Project Sdk="Microsoft.NET.Sdk">
719
+ <PropertyGroup>
720
+ <TargetFramework>net8.0</TargetFramework>
721
+ </PropertyGroup>
722
+ <ItemGroup>
723
+ <PackageReference Include="Microsoft.CodeAnalysis.Compilers" Version="4.9.2" />
724
+ <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.9.2" />
725
+ <PackageReference Include="Microsoft.CodeAnalysis.VisualBasic" Version="4.9.2" />
726
+ <PackageReference Include="Newtonsoft.Json.Bson" Version="1.0.2" />
727
+ </ItemGroup>
728
+ </Project>
729
+ """);
789
730
 
790
- try
731
+ var dependencies = new[]
791
732
  {
792
- var projectPath = Path.Join(repoRoot.FullName, "project.csproj");
793
- await File.WriteAllTextAsync(projectPath, """
794
- <Project Sdk="Microsoft.NET.Sdk">
795
- <PropertyGroup>
796
- <TargetFramework>net8.0</TargetFramework>
797
- </PropertyGroup>
798
- <ItemGroup>
799
- <PackageReference Include="Microsoft.CodeAnalysis.Compilers" Version="4.9.2" />
800
- <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.9.2" />
801
- <PackageReference Include="Microsoft.CodeAnalysis.VisualBasic" Version="4.9.2" />
802
- <PackageReference Include="Newtonsoft.Json.Bson" Version="1.0.2" />
803
- </ItemGroup>
804
- </Project>
805
- """);
806
-
807
- var dependencies = new[]
808
- {
809
- new Dependency("Microsoft.CodeAnalysis.Compilers", "4.9.2", DependencyType.PackageReference),
810
- new Dependency("Microsoft.CodeAnalysis.CSharp", "4.9.2", DependencyType.PackageReference),
811
- new Dependency("Microsoft.CodeAnalysis.VisualBasic", "4.9.2", DependencyType.PackageReference),
812
- new Dependency("Newtonsoft.Json.Bson", "1.0.2", DependencyType.PackageReference)
813
- };
814
- var update = new[]
815
- {
816
- new Dependency("Microsoft.CodeAnalysis.Common", "4.10.0", DependencyType.PackageReference),
817
- new Dependency("Newtonsoft.Json", "13.0.1", DependencyType.Unknown)
818
- };
819
-
820
- var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(repoRoot.FullName, projectPath, "net8.0", dependencies, update, new TestLogger());
821
- Assert.NotNull(resolvedDependencies);
822
- Assert.Equal(5, resolvedDependencies.Length);
823
- Assert.Equal("Microsoft.CodeAnalysis.Compilers", resolvedDependencies[0].Name);
824
- Assert.Equal("4.10.0", resolvedDependencies[0].Version);
825
- Assert.Equal("Microsoft.CodeAnalysis.CSharp", resolvedDependencies[1].Name);
826
- Assert.Equal("4.10.0", resolvedDependencies[1].Version);
827
- Assert.Equal("Microsoft.CodeAnalysis.VisualBasic", resolvedDependencies[2].Name);
828
- Assert.Equal("4.10.0", resolvedDependencies[2].Version);
829
- Assert.Equal("Newtonsoft.Json.Bson", resolvedDependencies[3].Name);
830
- Assert.Equal("1.0.2", resolvedDependencies[3].Version);
831
- Assert.Equal("Newtonsoft.Json", resolvedDependencies[4].Name);
832
- Assert.Equal("13.0.1", resolvedDependencies[4].Version);
833
- }
834
- finally
733
+ new Dependency("Microsoft.CodeAnalysis.Compilers", "4.9.2", DependencyType.PackageReference),
734
+ new Dependency("Microsoft.CodeAnalysis.CSharp", "4.9.2", DependencyType.PackageReference),
735
+ new Dependency("Microsoft.CodeAnalysis.VisualBasic", "4.9.2", DependencyType.PackageReference),
736
+ new Dependency("Newtonsoft.Json.Bson", "1.0.2", DependencyType.PackageReference)
737
+ };
738
+ var update = new[]
835
739
  {
836
- repoRoot.Delete(recursive: true);
837
- }
740
+ new Dependency("Microsoft.CodeAnalysis.Common", "4.10.0", DependencyType.PackageReference),
741
+ new Dependency("Newtonsoft.Json", "13.0.1", DependencyType.Unknown)
742
+ };
743
+
744
+ var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(tempDirectory.DirectoryPath, projectPath, "net8.0", dependencies, update, new TestLogger());
745
+ Assert.NotNull(resolvedDependencies);
746
+ Assert.Equal(5, resolvedDependencies.Length);
747
+ Assert.Equal("Microsoft.CodeAnalysis.Compilers", resolvedDependencies[0].Name);
748
+ Assert.Equal("4.10.0", resolvedDependencies[0].Version);
749
+ Assert.Equal("Microsoft.CodeAnalysis.CSharp", resolvedDependencies[1].Name);
750
+ Assert.Equal("4.10.0", resolvedDependencies[1].Version);
751
+ Assert.Equal("Microsoft.CodeAnalysis.VisualBasic", resolvedDependencies[2].Name);
752
+ Assert.Equal("4.10.0", resolvedDependencies[2].Version);
753
+ Assert.Equal("Newtonsoft.Json.Bson", resolvedDependencies[3].Name);
754
+ Assert.Equal("1.0.2", resolvedDependencies[3].Version);
755
+ Assert.Equal("Newtonsoft.Json", resolvedDependencies[4].Name);
756
+ Assert.Equal("13.0.1", resolvedDependencies[4].Version);
838
757
  }
839
758
 
840
759
  // Two top level packages (Buildalyzer), (Microsoft.CodeAnalysis.CSharp.Scripting) that share a dependency (Microsoft.CodeAnalysis.Csharp)
@@ -845,53 +764,45 @@ public class MSBuildHelperTests : TestBase
845
764
  [Fact]
846
765
  public async Task DependencyConflictsCanBeResolvedNewSharingDependency()
847
766
  {
848
- var repoRoot = Directory.CreateTempSubdirectory($"test_{nameof(DependencyConflictsCanBeResolvedNewSharingDependency)}_");
767
+ using var tempDirectory = new TemporaryDirectory();
768
+ var projectPath = Path.Join(tempDirectory.DirectoryPath, "project.csproj");
769
+ await File.WriteAllTextAsync(projectPath, """
770
+ <Project Sdk="Microsoft.NET.Sdk">
771
+ <PropertyGroup>
772
+ <TargetFramework>net8.0</TargetFramework>
773
+ </PropertyGroup>
774
+ <ItemGroup>
775
+ <PackageReference Include="Buildalyzer" Version="6.0.4" />
776
+ <PackageReference Include="Microsoft.CodeAnalysis.Csharp.Scripting" Version="3.10.0" />
777
+ <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.10.0" />
778
+ <PackageReference Include="Microsoft.CodeAnalysis.Common" Version="3.10.0" />
779
+ </ItemGroup>
780
+ </Project>
781
+ """);
849
782
 
850
- try
783
+ var dependencies = new[]
851
784
  {
852
- var projectPath = Path.Join(repoRoot.FullName, "project.csproj");
853
- await File.WriteAllTextAsync(projectPath, """
854
- <Project Sdk="Microsoft.NET.Sdk">
855
- <PropertyGroup>
856
- <TargetFramework>net8.0</TargetFramework>
857
- </PropertyGroup>
858
- <ItemGroup>
859
- <PackageReference Include="Buildalyzer" Version="6.0.4" />
860
- <PackageReference Include="Microsoft.CodeAnalysis.Csharp.Scripting" Version="3.10.0" />
861
- <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.10.0" />
862
- <PackageReference Include="Microsoft.CodeAnalysis.Common" Version="3.10.0" />
863
- </ItemGroup>
864
- </Project>
865
- """);
866
-
867
- var dependencies = new[]
868
- {
869
- new Dependency("Buildalyzer", "6.0.4", DependencyType.PackageReference),
870
- new Dependency("Microsoft.CodeAnalysis.CSharp.Scripting", "3.10.0", DependencyType.PackageReference),
871
- new Dependency("Microsoft.CodeAnalysis.CSharp", "3.10.0", DependencyType.PackageReference),
872
- new Dependency("Microsoft.CodeAnalysis.Common", "3.10.0", DependencyType.PackageReference),
873
- };
874
- var update = new[]
875
- {
876
- new Dependency("Buildalyzer", "7.0.1", DependencyType.PackageReference),
877
- };
878
-
879
- var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(repoRoot.FullName, projectPath, "net8.0", dependencies, update, new TestLogger());
880
- Assert.NotNull(resolvedDependencies);
881
- Assert.Equal(4, resolvedDependencies.Length);
882
- Assert.Equal("Buildalyzer", resolvedDependencies[0].Name);
883
- Assert.Equal("7.0.1", resolvedDependencies[0].Version);
884
- Assert.Equal("Microsoft.CodeAnalysis.CSharp.Scripting", resolvedDependencies[1].Name);
885
- Assert.Equal("4.0.0", resolvedDependencies[1].Version);
886
- Assert.Equal("Microsoft.CodeAnalysis.CSharp", resolvedDependencies[2].Name);
887
- Assert.Equal("4.0.0", resolvedDependencies[2].Version);
888
- Assert.Equal("Microsoft.CodeAnalysis.Common", resolvedDependencies[3].Name);
889
- Assert.Equal("4.0.0", resolvedDependencies[3].Version);
890
- }
891
- finally
785
+ new Dependency("Buildalyzer", "6.0.4", DependencyType.PackageReference),
786
+ new Dependency("Microsoft.CodeAnalysis.CSharp.Scripting", "3.10.0", DependencyType.PackageReference),
787
+ new Dependency("Microsoft.CodeAnalysis.CSharp", "3.10.0", DependencyType.PackageReference),
788
+ new Dependency("Microsoft.CodeAnalysis.Common", "3.10.0", DependencyType.PackageReference),
789
+ };
790
+ var update = new[]
892
791
  {
893
- repoRoot.Delete(recursive: true);
894
- }
792
+ new Dependency("Buildalyzer", "7.0.1", DependencyType.PackageReference),
793
+ };
794
+
795
+ var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(tempDirectory.DirectoryPath, projectPath, "net8.0", dependencies, update, new TestLogger());
796
+ 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);
895
806
  }
896
807
 
897
808
  // Updating two families at once to test efficiency
@@ -900,114 +811,98 @@ public class MSBuildHelperTests : TestBase
900
811
  [Fact]
901
812
  public async Task DependencyConflictsCanBeResolvedNewUpdatingEntireFamily()
902
813
  {
903
- var repoRoot = Directory.CreateTempSubdirectory($"test_{nameof(DependencyConflictsCanBeResolvedNewUpdatingEntireFamily)}_");
814
+ using var tempDirectory = new TemporaryDirectory();
815
+ var projectPath = Path.Join(tempDirectory.DirectoryPath, "project.csproj");
816
+ await File.WriteAllTextAsync(projectPath, """
817
+ <Project Sdk="Microsoft.NET.Sdk">
818
+ <PropertyGroup>
819
+ <TargetFramework>net8.0</TargetFramework>
820
+ </PropertyGroup>
821
+ <ItemGroup>
822
+ <PackageReference Include="System.Collections.Immutable" Version="7.0.0" />
823
+ <PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.8.0" />
824
+ <PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="1.0.0" />
825
+ <PackageReference Include="Azure.Core" Version="1.21.0" />
826
+ </ItemGroup>
827
+ </Project>
828
+ """);
904
829
 
905
- try
830
+ var dependencies = new[]
906
831
  {
907
- var projectPath = Path.Join(repoRoot.FullName, "project.csproj");
908
- await File.WriteAllTextAsync(projectPath, """
909
- <Project Sdk="Microsoft.NET.Sdk">
910
- <PropertyGroup>
911
- <TargetFramework>net8.0</TargetFramework>
912
- </PropertyGroup>
913
- <ItemGroup>
914
- <PackageReference Include="System.Collections.Immutable" Version="7.0.0" />
915
- <PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.8.0" />
916
- <PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="1.0.0" />
917
- <PackageReference Include="Azure.Core" Version="1.21.0" />
918
- </ItemGroup>
919
- </Project>
920
- """);
921
-
922
- var dependencies = new[]
923
- {
924
- new Dependency("System.Collections.Immutable", "7.0.0", DependencyType.PackageReference),
925
- new Dependency("Microsoft.CodeAnalysis.CSharp.Scripting", "4.8.0", DependencyType.PackageReference),
926
- new Dependency("Microsoft.Bcl.AsyncInterfaces", "1.0.0", DependencyType.Unknown),
927
- new Dependency("Azure.Core", "1.21.0", DependencyType.PackageReference),
928
-
929
- };
930
- var update = new[]
931
- {
932
- new Dependency("Microsoft.CodeAnalysis.Common", "4.10.0", DependencyType.PackageReference),
933
- new Dependency("Azure.Core", "1.22.0", DependencyType.PackageReference)
934
- };
832
+ new Dependency("System.Collections.Immutable", "7.0.0", DependencyType.PackageReference),
833
+ new Dependency("Microsoft.CodeAnalysis.CSharp.Scripting", "4.8.0", DependencyType.PackageReference),
834
+ new Dependency("Microsoft.Bcl.AsyncInterfaces", "1.0.0", DependencyType.Unknown),
835
+ new Dependency("Azure.Core", "1.21.0", DependencyType.PackageReference),
935
836
 
936
- var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(repoRoot.FullName, projectPath, "net8.0", dependencies, update, new TestLogger());
937
- Assert.NotNull(resolvedDependencies);
938
- Assert.Equal(4, resolvedDependencies.Length);
939
- Assert.Equal("System.Collections.Immutable", resolvedDependencies[0].Name);
940
- Assert.Equal("8.0.0", resolvedDependencies[0].Version);
941
- Assert.Equal("Microsoft.CodeAnalysis.CSharp.Scripting", resolvedDependencies[1].Name);
942
- Assert.Equal("4.10.0", resolvedDependencies[1].Version);
943
- Assert.Equal("Microsoft.Bcl.AsyncInterfaces", resolvedDependencies[2].Name);
944
- Assert.Equal("1.1.1", resolvedDependencies[2].Version);
945
- Assert.Equal("Azure.Core", resolvedDependencies[3].Name);
946
- Assert.Equal("1.22.0", resolvedDependencies[3].Version);
947
- }
948
- finally
837
+ };
838
+ var update = new[]
949
839
  {
950
- repoRoot.Delete(recursive: true);
951
- }
840
+ new Dependency("Microsoft.CodeAnalysis.Common", "4.10.0", DependencyType.PackageReference),
841
+ new Dependency("Azure.Core", "1.22.0", DependencyType.PackageReference)
842
+ };
843
+
844
+ var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(tempDirectory.DirectoryPath, projectPath, "net8.0", dependencies, update, new TestLogger());
845
+ Assert.NotNull(resolvedDependencies);
846
+ Assert.Equal(4, resolvedDependencies.Length);
847
+ Assert.Equal("System.Collections.Immutable", resolvedDependencies[0].Name);
848
+ Assert.Equal("8.0.0", resolvedDependencies[0].Version);
849
+ Assert.Equal("Microsoft.CodeAnalysis.CSharp.Scripting", resolvedDependencies[1].Name);
850
+ Assert.Equal("4.10.0", resolvedDependencies[1].Version);
851
+ Assert.Equal("Microsoft.Bcl.AsyncInterfaces", resolvedDependencies[2].Name);
852
+ Assert.Equal("1.1.1", resolvedDependencies[2].Version);
853
+ Assert.Equal("Azure.Core", resolvedDependencies[3].Name);
854
+ Assert.Equal("1.22.0", resolvedDependencies[3].Version);
952
855
  }
953
856
 
954
857
  // Similar to the last test, except Microsoft.CodeAnalysis.Common is in the existing list
955
858
  [Fact]
956
859
  public async Task DependencyConflictsCanBeResolvedNewUpdatingTopLevelAndDependency()
957
860
  {
958
- var repoRoot = Directory.CreateTempSubdirectory($"test_{nameof(DependencyConflictsCanBeResolvedNewUpdatingTopLevelAndDependency)}_");
861
+ using var tempDirectory = new TemporaryDirectory();
862
+ var projectPath = Path.Join(tempDirectory.DirectoryPath, "project.csproj");
863
+ await File.WriteAllTextAsync(projectPath, """
864
+ <Project Sdk="Microsoft.NET.Sdk">
865
+ <PropertyGroup>
866
+ <TargetFramework>net8.0</TargetFramework>
867
+ </PropertyGroup>
868
+ <ItemGroup>
869
+ <PackageReference Include="System.Collections.Immutable" Version="7.0.0" />
870
+ <PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.8.0" />
871
+ <PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.8.0" />
872
+ <PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="1.0.0" />
873
+ <PackageReference Include="Azure.Core" Version="1.21.0" />
874
+ </ItemGroup>
875
+ </Project>
876
+ """);
959
877
 
960
- try
878
+ var dependencies = new[]
961
879
  {
962
- var projectPath = Path.Join(repoRoot.FullName, "project.csproj");
963
- await File.WriteAllTextAsync(projectPath, """
964
- <Project Sdk="Microsoft.NET.Sdk">
965
- <PropertyGroup>
966
- <TargetFramework>net8.0</TargetFramework>
967
- </PropertyGroup>
968
- <ItemGroup>
969
- <PackageReference Include="System.Collections.Immutable" Version="7.0.0" />
970
- <PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.8.0" />
971
- <PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.8.0" />
972
- <PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="1.0.0" />
973
- <PackageReference Include="Azure.Core" Version="1.21.0" />
974
- </ItemGroup>
975
- </Project>
976
- """);
977
-
978
- var dependencies = new[]
979
- {
980
- new Dependency("System.Collections.Immutable", "7.0.0", DependencyType.PackageReference),
981
- new Dependency("Microsoft.CodeAnalysis.CSharp.Scripting", "4.8.0", DependencyType.PackageReference),
982
- new Dependency("Microsoft.CodeAnalysis.Common", "4.8.0", DependencyType.PackageReference),
983
- new Dependency("Microsoft.Bcl.AsyncInterfaces", "1.0.0", DependencyType.Unknown),
984
- new Dependency("Azure.Core", "1.21.0", DependencyType.PackageReference),
985
-
986
- };
987
- var update = new[]
988
- {
989
- new Dependency("Microsoft.CodeAnalysis.Common", "4.10.0", DependencyType.PackageReference),
990
- new Dependency("Azure.Core", "1.22.0", DependencyType.PackageReference)
991
- };
880
+ new Dependency("System.Collections.Immutable", "7.0.0", DependencyType.PackageReference),
881
+ new Dependency("Microsoft.CodeAnalysis.CSharp.Scripting", "4.8.0", DependencyType.PackageReference),
882
+ new Dependency("Microsoft.CodeAnalysis.Common", "4.8.0", DependencyType.PackageReference),
883
+ new Dependency("Microsoft.Bcl.AsyncInterfaces", "1.0.0", DependencyType.Unknown),
884
+ new Dependency("Azure.Core", "1.21.0", DependencyType.PackageReference),
992
885
 
993
- var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(repoRoot.FullName, projectPath, "net8.0", dependencies, update, new TestLogger());
994
- Assert.NotNull(resolvedDependencies);
995
- Assert.Equal(5, resolvedDependencies.Length);
996
- Assert.Equal("System.Collections.Immutable", resolvedDependencies[0].Name);
997
- Assert.Equal("8.0.0", resolvedDependencies[0].Version);
998
- Assert.Equal("Microsoft.CodeAnalysis.CSharp.Scripting", resolvedDependencies[1].Name);
999
- Assert.Equal("4.10.0", resolvedDependencies[1].Version);
1000
- Assert.Equal("Microsoft.CodeAnalysis.Common", resolvedDependencies[2].Name);
1001
- Assert.Equal("4.10.0", resolvedDependencies[2].Version);
1002
- Assert.Equal("Microsoft.Bcl.AsyncInterfaces", resolvedDependencies[3].Name);
1003
- Assert.Equal("1.1.1", resolvedDependencies[3].Version);
1004
- Assert.Equal("Azure.Core", resolvedDependencies[4].Name);
1005
- Assert.Equal("1.22.0", resolvedDependencies[4].Version);
1006
- }
1007
- finally
886
+ };
887
+ var update = new[]
1008
888
  {
1009
- repoRoot.Delete(recursive: true);
1010
- }
889
+ new Dependency("Microsoft.CodeAnalysis.Common", "4.10.0", DependencyType.PackageReference),
890
+ new Dependency("Azure.Core", "1.22.0", DependencyType.PackageReference)
891
+ };
892
+
893
+ var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(tempDirectory.DirectoryPath, projectPath, "net8.0", dependencies, update, new TestLogger());
894
+ Assert.NotNull(resolvedDependencies);
895
+ Assert.Equal(5, resolvedDependencies.Length);
896
+ Assert.Equal("System.Collections.Immutable", resolvedDependencies[0].Name);
897
+ Assert.Equal("8.0.0", resolvedDependencies[0].Version);
898
+ Assert.Equal("Microsoft.CodeAnalysis.CSharp.Scripting", resolvedDependencies[1].Name);
899
+ Assert.Equal("4.10.0", resolvedDependencies[1].Version);
900
+ Assert.Equal("Microsoft.CodeAnalysis.Common", resolvedDependencies[2].Name);
901
+ Assert.Equal("4.10.0", resolvedDependencies[2].Version);
902
+ Assert.Equal("Microsoft.Bcl.AsyncInterfaces", resolvedDependencies[3].Name);
903
+ Assert.Equal("1.1.1", resolvedDependencies[3].Version);
904
+ Assert.Equal("Azure.Core", resolvedDependencies[4].Name);
905
+ Assert.Equal("1.22.0", resolvedDependencies[4].Version);
1011
906
  }
1012
907
 
1013
908
  // Out of scope test: AutoMapper.Extensions.Microsoft.DependencyInjection's versions are not yet compatible
@@ -1016,94 +911,78 @@ public class MSBuildHelperTests : TestBase
1016
911
  [Fact]
1017
912
  public async Task DependencyConflictsCanBeResolvedNewOutOfScope()
1018
913
  {
1019
- var repoRoot = Directory.CreateTempSubdirectory($"test_{nameof(DependencyConflictsCanBeResolvedNewOutOfScope)}_");
914
+ using var tempDirectory = new TemporaryDirectory();
915
+ var projectPath = Path.Join(tempDirectory.DirectoryPath, "project.csproj");
916
+ await File.WriteAllTextAsync(projectPath, """
917
+ <Project Sdk="Microsoft.NET.Sdk">
918
+ <PropertyGroup>
919
+ <TargetFramework>net8.0</TargetFramework>
920
+ </PropertyGroup>
921
+ <ItemGroup>
922
+ <PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
923
+ <PackageReference Include="AutoMapper" Version="12.0.1" />
924
+ <PackageReference Include="AutoMapper.Collection" Version="9.0.0" />
925
+ </ItemGroup>
926
+ </Project>
927
+ """);
1020
928
 
1021
- try
929
+ var dependencies = new[]
1022
930
  {
1023
- var projectPath = Path.Join(repoRoot.FullName, "project.csproj");
1024
- await File.WriteAllTextAsync(projectPath, """
1025
- <Project Sdk="Microsoft.NET.Sdk">
1026
- <PropertyGroup>
1027
- <TargetFramework>net8.0</TargetFramework>
1028
- </PropertyGroup>
1029
- <ItemGroup>
1030
- <PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
1031
- <PackageReference Include="AutoMapper" Version="12.0.1" />
1032
- <PackageReference Include="AutoMapper.Collection" Version="9.0.0" />
1033
- </ItemGroup>
1034
- </Project>
1035
- """);
1036
-
1037
- var dependencies = new[]
1038
- {
1039
- new Dependency("AutoMapper.Extensions.Microsoft.DependencyInjection", "12.0.1", DependencyType.PackageReference),
1040
- new Dependency("AutoMapper", "12.0.1", DependencyType.PackageReference),
1041
- new Dependency("AutoMapper.Collection", "9.0.0", DependencyType.PackageReference)
1042
- };
1043
- var update = new[]
1044
- {
1045
- new Dependency("AutoMapper.Collection", "10.0.0", DependencyType.PackageReference)
1046
- };
1047
-
1048
- var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(repoRoot.FullName, projectPath, "net8.0", dependencies, update, new TestLogger());
1049
- Assert.NotNull(resolvedDependencies);
1050
- Assert.Equal(3, resolvedDependencies.Length);
1051
- Assert.Equal("AutoMapper.Extensions.Microsoft.DependencyInjection", resolvedDependencies[0].Name);
1052
- Assert.Equal("12.0.1", resolvedDependencies[0].Version);
1053
- Assert.Equal("AutoMapper", resolvedDependencies[1].Name);
1054
- Assert.Equal("12.0.1", resolvedDependencies[1].Version);
1055
- Assert.Equal("AutoMapper.Collection", resolvedDependencies[2].Name);
1056
- Assert.Equal("9.0.0", resolvedDependencies[2].Version);
1057
- }
1058
- finally
931
+ new Dependency("AutoMapper.Extensions.Microsoft.DependencyInjection", "12.0.1", DependencyType.PackageReference),
932
+ new Dependency("AutoMapper", "12.0.1", DependencyType.PackageReference),
933
+ new Dependency("AutoMapper.Collection", "9.0.0", DependencyType.PackageReference)
934
+ };
935
+ var update = new[]
1059
936
  {
1060
- repoRoot.Delete(recursive: true);
1061
- }
937
+ new Dependency("AutoMapper.Collection", "10.0.0", DependencyType.PackageReference)
938
+ };
939
+
940
+ var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(tempDirectory.DirectoryPath, projectPath, "net8.0", dependencies, update, new TestLogger());
941
+ Assert.NotNull(resolvedDependencies);
942
+ Assert.Equal(3, resolvedDependencies.Length);
943
+ Assert.Equal("AutoMapper.Extensions.Microsoft.DependencyInjection", resolvedDependencies[0].Name);
944
+ Assert.Equal("12.0.1", resolvedDependencies[0].Version);
945
+ Assert.Equal("AutoMapper", resolvedDependencies[1].Name);
946
+ Assert.Equal("12.0.1", resolvedDependencies[1].Version);
947
+ Assert.Equal("AutoMapper.Collection", resolvedDependencies[2].Name);
948
+ Assert.Equal("9.0.0", resolvedDependencies[2].Version);
1062
949
  }
1063
950
 
1064
951
  // Two dependencies (Microsoft.Extensions.Caching.Memory), (Microsoft.EntityFrameworkCore.Analyzers) used by the same parent (Microsoft.EntityFrameworkCore), updating one of the dependencies
1065
952
  [Fact]
1066
953
  public async Task DependencyConflictsCanBeResolvedNewTwoDependenciesShareSameParent()
1067
954
  {
1068
- var repoRoot = Directory.CreateTempSubdirectory($"test_{nameof(DependencyConflictsCanBeResolvedNewTwoDependenciesShareSameParent)}_");
955
+ using var tempDirectory = new TemporaryDirectory();
956
+ var projectPath = Path.Join(tempDirectory.DirectoryPath, "project.csproj");
957
+ await File.WriteAllTextAsync(projectPath, """
958
+ <Project Sdk="Microsoft.NET.Sdk">
959
+ <PropertyGroup>
960
+ <TargetFramework>net8.0</TargetFramework>
961
+ </PropertyGroup>
962
+ <ItemGroup>
963
+ <PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.11" />
964
+ <PackageReference Include="Microsoft.EntityFrameworkCore.Analyzers" Version="7.0.11" />
965
+ </ItemGroup>
966
+ </Project>
967
+ """);
1069
968
 
1070
- try
969
+ var dependencies = new[]
1071
970
  {
1072
- var projectPath = Path.Join(repoRoot.FullName, "project.csproj");
1073
- await File.WriteAllTextAsync(projectPath, """
1074
- <Project Sdk="Microsoft.NET.Sdk">
1075
- <PropertyGroup>
1076
- <TargetFramework>net8.0</TargetFramework>
1077
- </PropertyGroup>
1078
- <ItemGroup>
1079
- <PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.11" />
1080
- <PackageReference Include="Microsoft.EntityFrameworkCore.Analyzers" Version="7.0.11" />
1081
- </ItemGroup>
1082
- </Project>
1083
- """);
1084
-
1085
- var dependencies = new[]
1086
- {
1087
- new Dependency("Microsoft.EntityFrameworkCore", "7.0.11", DependencyType.PackageReference),
1088
- new Dependency("Microsoft.EntityFrameworkCore.Analyzers", "7.0.11", DependencyType.PackageReference)
1089
- };
1090
- var update = new[]
1091
- {
1092
- new Dependency("Microsoft.Extensions.Caching.Memory", "8.0.0", DependencyType.PackageReference)
1093
- };
1094
-
1095
- var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(repoRoot.FullName, projectPath, "net8.0", dependencies, update, new TestLogger());
1096
- Assert.NotNull(resolvedDependencies);
1097
- Assert.Equal(2, resolvedDependencies.Length);
1098
- Assert.Equal("Microsoft.EntityFrameworkCore", resolvedDependencies[0].Name);
1099
- Assert.Equal("8.0.0", resolvedDependencies[0].Version);
1100
- Assert.Equal("Microsoft.EntityFrameworkCore.Analyzers", resolvedDependencies[1].Name);
1101
- Assert.Equal("8.0.0", resolvedDependencies[1].Version);
1102
- }
1103
- finally
971
+ new Dependency("Microsoft.EntityFrameworkCore", "7.0.11", DependencyType.PackageReference),
972
+ new Dependency("Microsoft.EntityFrameworkCore.Analyzers", "7.0.11", DependencyType.PackageReference)
973
+ };
974
+ var update = new[]
1104
975
  {
1105
- repoRoot.Delete(recursive: true);
1106
- }
976
+ new Dependency("Microsoft.Extensions.Caching.Memory", "8.0.0", DependencyType.PackageReference)
977
+ };
978
+
979
+ var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(tempDirectory.DirectoryPath, projectPath, "net8.0", dependencies, update, new TestLogger());
980
+ Assert.NotNull(resolvedDependencies);
981
+ Assert.Equal(2, resolvedDependencies.Length);
982
+ Assert.Equal("Microsoft.EntityFrameworkCore", resolvedDependencies[0].Name);
983
+ Assert.Equal("8.0.0", resolvedDependencies[0].Version);
984
+ Assert.Equal("Microsoft.EntityFrameworkCore.Analyzers", resolvedDependencies[1].Name);
985
+ Assert.Equal("8.0.0", resolvedDependencies[1].Version);
1107
986
  }
1108
987
 
1109
988
  // Updating referenced package
@@ -1111,53 +990,45 @@ public class MSBuildHelperTests : TestBase
1111
990
  [Fact]
1112
991
  public async Task DependencyConflictsCanBeResolvedNewFamilyOfFourExisting()
1113
992
  {
1114
- var repoRoot = Directory.CreateTempSubdirectory($"test_{nameof(DependencyConflictsCanBeResolvedNewFamilyOfFourExisting)}_");
993
+ using var tempDirectory = new TemporaryDirectory();
994
+ var projectPath = Path.Join(tempDirectory.DirectoryPath, "project.csproj");
995
+ await File.WriteAllTextAsync(projectPath, """
996
+ <Project Sdk="Microsoft.NET.Sdk">
997
+ <PropertyGroup>
998
+ <TargetFramework>net8.0</TargetFramework>
999
+ </PropertyGroup>
1000
+ <ItemGroup>
1001
+ <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.0" />
1002
+ <PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="7.0.0" />
1003
+ <PackageReference Include= "Microsoft.EntityFrameworkCore" Version="7.0.0" />
1004
+ <PackageReference Include="Microsoft.EntityFrameworkCore.Analyzers" Version="7.0.0" />
1005
+ </ItemGroup>
1006
+ </Project>
1007
+ """);
1115
1008
 
1116
- try
1009
+ var dependencies = new[]
1117
1010
  {
1118
- var projectPath = Path.Join(repoRoot.FullName, "project.csproj");
1119
- await File.WriteAllTextAsync(projectPath, """
1120
- <Project Sdk="Microsoft.NET.Sdk">
1121
- <PropertyGroup>
1122
- <TargetFramework>net8.0</TargetFramework>
1123
- </PropertyGroup>
1124
- <ItemGroup>
1125
- <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.0" />
1126
- <PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="7.0.0" />
1127
- <PackageReference Include= "Microsoft.EntityFrameworkCore" Version="7.0.0" />
1128
- <PackageReference Include="Microsoft.EntityFrameworkCore.Analyzers" Version="7.0.0" />
1129
- </ItemGroup>
1130
- </Project>
1131
- """);
1132
-
1133
- var dependencies = new[]
1134
- {
1135
- new Dependency("Microsoft.EntityFrameworkCore.Design", "7.0.0", DependencyType.PackageReference),
1136
- new Dependency("Microsoft.EntityFrameworkCore.Relational", "7.0.0", DependencyType.PackageReference),
1137
- new Dependency("Microsoft.EntityFrameworkCore", "7.0.0", DependencyType.PackageReference),
1138
- new Dependency("Microsoft.EntityFrameworkCore.Analyzers", "7.0.0", DependencyType.PackageReference)
1139
- };
1140
- var update = new[]
1141
- {
1142
- new Dependency("Microsoft.EntityFrameworkCore.Analyzers", "8.0.0", DependencyType.PackageReference)
1143
- };
1144
-
1145
- var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(repoRoot.FullName, projectPath, "net8.0", dependencies, update, new TestLogger());
1146
- Assert.NotNull(resolvedDependencies);
1147
- Assert.Equal(4, resolvedDependencies.Length);
1148
- Assert.Equal("Microsoft.EntityFrameworkCore.Design", resolvedDependencies[0].Name);
1149
- Assert.Equal("7.0.0", resolvedDependencies[0].Version);
1150
- Assert.Equal("Microsoft.EntityFrameworkCore.Relational", resolvedDependencies[1].Name);
1151
- Assert.Equal("7.0.0", resolvedDependencies[1].Version);
1152
- Assert.Equal("Microsoft.EntityFrameworkCore", resolvedDependencies[2].Name);
1153
- Assert.Equal("7.0.0", resolvedDependencies[2].Version);
1154
- Assert.Equal("Microsoft.EntityFrameworkCore.Analyzers", resolvedDependencies[3].Name);
1155
- Assert.Equal("8.0.0", resolvedDependencies[3].Version);
1156
- }
1157
- finally
1011
+ new Dependency("Microsoft.EntityFrameworkCore.Design", "7.0.0", DependencyType.PackageReference),
1012
+ new Dependency("Microsoft.EntityFrameworkCore.Relational", "7.0.0", DependencyType.PackageReference),
1013
+ new Dependency("Microsoft.EntityFrameworkCore", "7.0.0", DependencyType.PackageReference),
1014
+ new Dependency("Microsoft.EntityFrameworkCore.Analyzers", "7.0.0", DependencyType.PackageReference)
1015
+ };
1016
+ var update = new[]
1158
1017
  {
1159
- repoRoot.Delete(recursive: true);
1160
- }
1018
+ new Dependency("Microsoft.EntityFrameworkCore.Analyzers", "8.0.0", DependencyType.PackageReference)
1019
+ };
1020
+
1021
+ var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(tempDirectory.DirectoryPath, projectPath, "net8.0", dependencies, update, new TestLogger());
1022
+ Assert.NotNull(resolvedDependencies);
1023
+ Assert.Equal(4, resolvedDependencies.Length);
1024
+ Assert.Equal("Microsoft.EntityFrameworkCore.Design", resolvedDependencies[0].Name);
1025
+ Assert.Equal("7.0.0", resolvedDependencies[0].Version);
1026
+ Assert.Equal("Microsoft.EntityFrameworkCore.Relational", resolvedDependencies[1].Name);
1027
+ Assert.Equal("7.0.0", resolvedDependencies[1].Version);
1028
+ Assert.Equal("Microsoft.EntityFrameworkCore", resolvedDependencies[2].Name);
1029
+ Assert.Equal("7.0.0", resolvedDependencies[2].Version);
1030
+ Assert.Equal("Microsoft.EntityFrameworkCore.Analyzers", resolvedDependencies[3].Name);
1031
+ Assert.Equal("8.0.0", resolvedDependencies[3].Version);
1161
1032
  }
1162
1033
 
1163
1034
  // Updating unreferenced package
@@ -1165,49 +1036,41 @@ public class MSBuildHelperTests : TestBase
1165
1036
  [Fact]
1166
1037
  public async Task DependencyConflictsCanBeResolvedNewFamilyOfFourNotInExisting()
1167
1038
  {
1168
- var repoRoot = Directory.CreateTempSubdirectory($"test_{nameof(DependencyConflictsCanBeResolvedNewFamilyOfFourNotInExisting)}_");
1039
+ using var tempDirectory = new TemporaryDirectory();
1040
+ var projectPath = Path.Join(tempDirectory.DirectoryPath, "project.csproj");
1041
+ await File.WriteAllTextAsync(projectPath, """
1042
+ <Project Sdk="Microsoft.NET.Sdk">
1043
+ <PropertyGroup>
1044
+ <TargetFramework>net8.0</TargetFramework>
1045
+ </PropertyGroup>
1046
+ <ItemGroup>
1047
+ <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.0" />
1048
+ <PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="7.0.0" />
1049
+ <PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.0" />
1050
+ </ItemGroup>
1051
+ </Project>
1052
+ """);
1169
1053
 
1170
- try
1054
+ var dependencies = new[]
1171
1055
  {
1172
- var projectPath = Path.Join(repoRoot.FullName, "project.csproj");
1173
- await File.WriteAllTextAsync(projectPath, """
1174
- <Project Sdk="Microsoft.NET.Sdk">
1175
- <PropertyGroup>
1176
- <TargetFramework>net8.0</TargetFramework>
1177
- </PropertyGroup>
1178
- <ItemGroup>
1179
- <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.0" />
1180
- <PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="7.0.0" />
1181
- <PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.0" />
1182
- </ItemGroup>
1183
- </Project>
1184
- """);
1185
-
1186
- var dependencies = new[]
1187
- {
1188
- new Dependency("Microsoft.EntityFrameworkCore.Design", "7.0.0", DependencyType.PackageReference),
1189
- new Dependency("Microsoft.EntityFrameworkCore.Relational", "7.0.0", DependencyType.PackageReference),
1190
- new Dependency("Microsoft.EntityFrameworkCore", "7.0.0", DependencyType.PackageReference),
1191
- };
1192
- var update = new[]
1193
- {
1194
- new Dependency("Microsoft.EntityFrameworkCore.Analyzers", "8.0.0", DependencyType.PackageReference)
1195
- };
1196
-
1197
- var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(repoRoot.FullName, projectPath, "net8.0", dependencies, update, new TestLogger());
1198
- Assert.NotNull(resolvedDependencies);
1199
- Assert.Equal(3, resolvedDependencies.Length);
1200
- Assert.Equal("Microsoft.EntityFrameworkCore.Design", resolvedDependencies[0].Name);
1201
- Assert.Equal("8.0.0", resolvedDependencies[0].Version);
1202
- Assert.Equal("Microsoft.EntityFrameworkCore.Relational", resolvedDependencies[1].Name);
1203
- Assert.Equal("8.0.0", resolvedDependencies[1].Version);
1204
- Assert.Equal("Microsoft.EntityFrameworkCore", resolvedDependencies[2].Name);
1205
- Assert.Equal("8.0.0", resolvedDependencies[2].Version);
1206
- }
1207
- finally
1056
+ new Dependency("Microsoft.EntityFrameworkCore.Design", "7.0.0", DependencyType.PackageReference),
1057
+ new Dependency("Microsoft.EntityFrameworkCore.Relational", "7.0.0", DependencyType.PackageReference),
1058
+ new Dependency("Microsoft.EntityFrameworkCore", "7.0.0", DependencyType.PackageReference),
1059
+ };
1060
+ var update = new[]
1208
1061
  {
1209
- repoRoot.Delete(recursive: true);
1210
- }
1062
+ new Dependency("Microsoft.EntityFrameworkCore.Analyzers", "8.0.0", DependencyType.PackageReference)
1063
+ };
1064
+
1065
+ var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(tempDirectory.DirectoryPath, projectPath, "net8.0", dependencies, update, new TestLogger());
1066
+ Assert.NotNull(resolvedDependencies);
1067
+ Assert.Equal(3, resolvedDependencies.Length);
1068
+ Assert.Equal("Microsoft.EntityFrameworkCore.Design", resolvedDependencies[0].Name);
1069
+ Assert.Equal("8.0.0", resolvedDependencies[0].Version);
1070
+ Assert.Equal("Microsoft.EntityFrameworkCore.Relational", resolvedDependencies[1].Name);
1071
+ Assert.Equal("8.0.0", resolvedDependencies[1].Version);
1072
+ Assert.Equal("Microsoft.EntityFrameworkCore", resolvedDependencies[2].Name);
1073
+ Assert.Equal("8.0.0", resolvedDependencies[2].Version);
1211
1074
  }
1212
1075
 
1213
1076
  // Updating a referenced transitive dependency
@@ -1215,103 +1078,87 @@ public class MSBuildHelperTests : TestBase
1215
1078
  [Fact]
1216
1079
  public async Task DependencyConflictsCanBeResolvedNewFamilyOfFourSpecificExisting()
1217
1080
  {
1218
- var repoRoot = Directory.CreateTempSubdirectory($"test_{nameof(DependencyConflictsCanBeResolvedNewFamilyOfFourSpecificExisting)}_");
1081
+ using var tempDirectory = new TemporaryDirectory();
1082
+ var projectPath = Path.Join(tempDirectory.DirectoryPath, "project.csproj");
1083
+ await File.WriteAllTextAsync(projectPath, """
1084
+ <Project Sdk="Microsoft.NET.Sdk">
1085
+ <PropertyGroup>
1086
+ <TargetFramework>net8.0</TargetFramework>
1087
+ </PropertyGroup>
1088
+ <ItemGroup>
1089
+ <PackageReference Include="System.Collections.Immutable" Version="7.0.0" />
1090
+ <PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.8.0" />
1091
+ <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.8.0" />
1092
+ <PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.8.0" />
1093
+ </ItemGroup>
1094
+ </Project>
1095
+ """);
1219
1096
 
1220
- try
1097
+ var dependencies = new[]
1221
1098
  {
1222
- var projectPath = Path.Join(repoRoot.FullName, "project.csproj");
1223
- await File.WriteAllTextAsync(projectPath, """
1224
- <Project Sdk="Microsoft.NET.Sdk">
1225
- <PropertyGroup>
1226
- <TargetFramework>net8.0</TargetFramework>
1227
- </PropertyGroup>
1228
- <ItemGroup>
1229
- <PackageReference Include="System.Collections.Immutable" Version="7.0.0" />
1230
- <PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.8.0" />
1231
- <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.8.0" />
1232
- <PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.8.0" />
1233
- </ItemGroup>
1234
- </Project>
1235
- """);
1236
-
1237
- var dependencies = new[]
1238
- {
1239
- new Dependency("System.Collections.Immutable", "7.0.0", DependencyType.PackageReference),
1240
- new Dependency("Microsoft.CodeAnalysis.CSharp.Workspaces", "4.8.0", DependencyType.PackageReference),
1241
- new Dependency("Microsoft.CodeAnalysis.CSharp", "4.8.0", DependencyType.PackageReference),
1242
- new Dependency("Microsoft.CodeAnalysis.Common", "4.8.0", DependencyType.PackageReference),
1243
- };
1244
- var update = new[]
1245
- {
1246
- new Dependency("System.Collections.Immutable", "8.0.0", DependencyType.PackageReference),
1247
- };
1248
-
1249
- var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(repoRoot.FullName, projectPath, "net8.0", dependencies, update, new TestLogger());
1250
- Assert.NotNull(resolvedDependencies);
1251
- Assert.Equal(4, resolvedDependencies.Length);
1252
- Assert.Equal("System.Collections.Immutable", resolvedDependencies[0].Name);
1253
- Assert.Equal("8.0.0", resolvedDependencies[0].Version);
1254
- Assert.Equal("Microsoft.CodeAnalysis.CSharp.Workspaces", resolvedDependencies[1].Name);
1255
- Assert.Equal("4.8.0", resolvedDependencies[1].Version);
1256
- Assert.Equal("Microsoft.CodeAnalysis.CSharp", resolvedDependencies[2].Name);
1257
- Assert.Equal("4.8.0", resolvedDependencies[2].Version);
1258
- Assert.Equal("Microsoft.CodeAnalysis.Common", resolvedDependencies[3].Name);
1259
- Assert.Equal("4.8.0", resolvedDependencies[3].Version);
1260
- }
1261
- finally
1099
+ new Dependency("System.Collections.Immutable", "7.0.0", DependencyType.PackageReference),
1100
+ new Dependency("Microsoft.CodeAnalysis.CSharp.Workspaces", "4.8.0", DependencyType.PackageReference),
1101
+ new Dependency("Microsoft.CodeAnalysis.CSharp", "4.8.0", DependencyType.PackageReference),
1102
+ new Dependency("Microsoft.CodeAnalysis.Common", "4.8.0", DependencyType.PackageReference),
1103
+ };
1104
+ var update = new[]
1262
1105
  {
1263
- repoRoot.Delete(recursive: true);
1264
- }
1106
+ new Dependency("System.Collections.Immutable", "8.0.0", DependencyType.PackageReference),
1107
+ };
1108
+
1109
+ var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(tempDirectory.DirectoryPath, projectPath, "net8.0", dependencies, update, new TestLogger());
1110
+ Assert.NotNull(resolvedDependencies);
1111
+ Assert.Equal(4, resolvedDependencies.Length);
1112
+ Assert.Equal("System.Collections.Immutable", resolvedDependencies[0].Name);
1113
+ Assert.Equal("8.0.0", resolvedDependencies[0].Version);
1114
+ Assert.Equal("Microsoft.CodeAnalysis.CSharp.Workspaces", resolvedDependencies[1].Name);
1115
+ Assert.Equal("4.8.0", resolvedDependencies[1].Version);
1116
+ Assert.Equal("Microsoft.CodeAnalysis.CSharp", resolvedDependencies[2].Name);
1117
+ Assert.Equal("4.8.0", resolvedDependencies[2].Version);
1118
+ Assert.Equal("Microsoft.CodeAnalysis.Common", resolvedDependencies[3].Name);
1119
+ Assert.Equal("4.8.0", resolvedDependencies[3].Version);
1265
1120
  }
1266
1121
 
1267
1122
  // Similar to the last test, with the "grandchild" (System.Collections.Immutable) not in the existing list
1268
1123
  [Fact]
1269
1124
  public async Task DependencyConflictsCanBeResolvedNewFamilyOfFourSpecificNotInExisting()
1270
1125
  {
1271
- var repoRoot = Directory.CreateTempSubdirectory($"test_{nameof(DependencyConflictsCanBeResolvedNewFamilyOfFourSpecificNotInExisting)}_");
1126
+ using var tempDirectory = new TemporaryDirectory();
1127
+ var projectPath = Path.Join(tempDirectory.DirectoryPath, "project.csproj");
1128
+ await File.WriteAllTextAsync(projectPath, """
1129
+ <Project Sdk="Microsoft.NET.Sdk">
1130
+ <PropertyGroup>
1131
+ <TargetFramework>net8.0</TargetFramework>
1132
+ </PropertyGroup>
1133
+ <ItemGroup>
1134
+ <PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.8.0" />
1135
+ <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.8.0" />
1136
+ <PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.8.0" />
1137
+ </ItemGroup>
1138
+ </Project>
1139
+ """);
1272
1140
 
1273
- try
1141
+ var dependencies = new[]
1274
1142
  {
1275
- var projectPath = Path.Join(repoRoot.FullName, "project.csproj");
1276
- await File.WriteAllTextAsync(projectPath, """
1277
- <Project Sdk="Microsoft.NET.Sdk">
1278
- <PropertyGroup>
1279
- <TargetFramework>net8.0</TargetFramework>
1280
- </PropertyGroup>
1281
- <ItemGroup>
1282
- <PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.8.0" />
1283
- <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.8.0" />
1284
- <PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.8.0" />
1285
- </ItemGroup>
1286
- </Project>
1287
- """);
1143
+ new Dependency("Microsoft.CodeAnalysis.CSharp.Workspaces", "4.8.0", DependencyType.PackageReference),
1144
+ new Dependency("Microsoft.CodeAnalysis.CSharp", "4.8.0", DependencyType.PackageReference),
1145
+ new Dependency("Microsoft.CodeAnalysis.Common", "4.8.0", DependencyType.PackageReference),
1288
1146
 
1289
- var dependencies = new[]
1290
- {
1291
- new Dependency("Microsoft.CodeAnalysis.CSharp.Workspaces", "4.8.0", DependencyType.PackageReference),
1292
- new Dependency("Microsoft.CodeAnalysis.CSharp", "4.8.0", DependencyType.PackageReference),
1293
- new Dependency("Microsoft.CodeAnalysis.Common", "4.8.0", DependencyType.PackageReference),
1294
-
1295
- };
1296
- var update = new[]
1297
- {
1298
- new Dependency("System.Collections.Immutable", "8.0.0", DependencyType.PackageReference),
1299
- };
1300
-
1301
- var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(repoRoot.FullName, projectPath, "net8.0", dependencies, update, new TestLogger());
1302
- Assert.NotNull(resolvedDependencies);
1303
- Assert.Equal(3, resolvedDependencies.Length);
1304
- Assert.Equal("Microsoft.CodeAnalysis.CSharp.Workspaces", resolvedDependencies[0].Name);
1305
- Assert.Equal("4.9.2", resolvedDependencies[0].Version);
1306
- Assert.Equal("Microsoft.CodeAnalysis.CSharp", resolvedDependencies[1].Name);
1307
- Assert.Equal("4.9.2", resolvedDependencies[1].Version);
1308
- Assert.Equal("Microsoft.CodeAnalysis.Common", resolvedDependencies[2].Name);
1309
- Assert.Equal("4.9.2", resolvedDependencies[2].Version);
1310
- }
1311
- finally
1147
+ };
1148
+ var update = new[]
1312
1149
  {
1313
- repoRoot.Delete(recursive: true);
1314
- }
1150
+ new Dependency("System.Collections.Immutable", "8.0.0", DependencyType.PackageReference),
1151
+ };
1152
+
1153
+ var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(tempDirectory.DirectoryPath, projectPath, "net8.0", dependencies, update, new TestLogger());
1154
+ Assert.NotNull(resolvedDependencies);
1155
+ Assert.Equal(3, resolvedDependencies.Length);
1156
+ Assert.Equal("Microsoft.CodeAnalysis.CSharp.Workspaces", resolvedDependencies[0].Name);
1157
+ Assert.Equal("4.9.2", resolvedDependencies[0].Version);
1158
+ Assert.Equal("Microsoft.CodeAnalysis.CSharp", resolvedDependencies[1].Name);
1159
+ Assert.Equal("4.9.2", resolvedDependencies[1].Version);
1160
+ Assert.Equal("Microsoft.CodeAnalysis.Common", resolvedDependencies[2].Name);
1161
+ Assert.Equal("4.9.2", resolvedDependencies[2].Version);
1315
1162
  }
1316
1163
  #endregion
1317
1164