dependabot-nuget 0.321.2 → 0.322.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/helpers/lib/NuGetUpdater/Directory.Packages.props +22 -22
  3. data/helpers/lib/NuGetUpdater/DotNetPackageCorrelation/Model/PackageMapper.cs +9 -0
  4. data/helpers/lib/NuGetUpdater/DotNetPackageCorrelation.Cli/Program.cs +21 -7
  5. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/AnalyzeCommand.cs +19 -11
  6. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/CloneCommand.cs +19 -9
  7. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/DiscoverCommand.cs +21 -14
  8. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/FrameworkCheckCommand.cs +8 -5
  9. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/RunCommand.cs +29 -16
  10. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/UpdateCommand.cs +20 -19
  11. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Program.cs +2 -1
  12. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/DependencyDiscoveryTargetingPacks.props +2 -0
  13. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/DependencySolver/IDependencySolver.cs +8 -0
  14. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/DependencySolver/MSBuildDependencySolver.cs +32 -0
  15. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/ProjectDiscoveryResult.cs +1 -0
  16. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/SdkProjectDiscovery.cs +10 -1
  17. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/WorkspaceDiscoveryResult.cs +6 -0
  18. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/ExperimentsManager.cs +3 -0
  19. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/GlobalJsonBuildFile.cs +5 -13
  20. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/PrivateSourceTimedOutException.cs +12 -0
  21. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/JobErrorBase.cs +4 -0
  22. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/PrivateSourceTimedOut.cs +10 -0
  23. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/PullRequestTextGenerator.cs +1 -1
  24. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/UpdateHandlers/CreateSecurityUpdatePullRequestHandler.cs +1 -1
  25. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/UpdateHandlers/GroupUpdateAllVersionsHandler.cs +2 -2
  26. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/UpdateHandlers/RefreshGroupUpdatePullRequestHandler.cs +1 -1
  27. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/UpdateHandlers/RefreshSecurityUpdatePullRequestHandler.cs +1 -1
  28. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/UpdateHandlers/RefreshVersionUpdatePullRequestHandler.cs +1 -1
  29. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/DotNetToolsJsonUpdater.cs +6 -3
  30. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/FileWriters/FileWriterWorker.cs +376 -0
  31. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/FileWriters/IFileWriter.cs +14 -0
  32. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/FileWriters/XmlFileWriter.cs +477 -0
  33. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/GlobalJsonUpdater.cs +9 -5
  34. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/UpdateOperationBase.cs +18 -7
  35. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/UpdaterWorker.cs +26 -1
  36. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/MSBuildHelper.cs +15 -0
  37. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/DependencySolver/MSBuildDependencySolverTests.cs +633 -0
  38. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.GlobalJson.cs +0 -2
  39. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.cs +0 -2
  40. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/SdkProjectDiscoveryTests.cs +49 -0
  41. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Files/GlobalJsonBuildFileTests.cs +0 -1
  42. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/EndToEndTests.cs +484 -0
  43. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/HttpApiHandlerTests.cs +1 -0
  44. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/JobErrorBaseTests.cs +7 -0
  45. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/MessageReportTests.cs +11 -0
  46. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/PullRequestTextTests.cs +21 -22
  47. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/RunWorkerTests.cs +1 -1
  48. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/SerializationTests.cs +8 -0
  49. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/DotNetToolsJsonUpdaterTests.cs +181 -0
  50. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/FileWriters/FileWriterTestsBase.cs +61 -0
  51. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/FileWriters/FileWriterWorkerTests.cs +917 -0
  52. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/FileWriters/FileWriterWorkerTests_MiscellaneousTests.cs +154 -0
  53. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/FileWriters/TestFileWriterReturnsConstantResult.cs +20 -0
  54. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/FileWriters/XmlFileWriterTests.cs +1620 -0
  55. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/FileWriters/XmlFileWriterTests_CreateUpdatedVersionRangeTests.cs +25 -0
  56. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/GlobalJsonUpdaterTests.cs +139 -0
  57. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/PackagesConfigUpdaterTests.cs +1961 -1
  58. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateOperationResultTests.cs +116 -0
  59. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/MSBuildHelperTests.cs +16 -1043
  60. data/helpers/lib/NuGetUpdater/global.json +1 -1
  61. metadata +21 -10
  62. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.DotNetTools.cs +0 -375
  63. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.GlobalJson.cs +0 -296
  64. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.LockFile.cs +0 -251
  65. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.Mixed.cs +0 -201
  66. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackageReference.cs +0 -3821
  67. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackagesConfig.cs +0 -2706
@@ -678,1049 +678,6 @@ public class MSBuildHelperTests : TestBase
678
678
  ];
679
679
  }
680
680
 
681
- #region
682
- // Updating root package
683
- // 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
684
- [Theory]
685
- [InlineData(true)]
686
- [InlineData(false)]
687
- public async Task DependencyConflictsCanBeResolvedNewUpdatingTopLevelPackage(bool useExistingSdks)
688
- {
689
- using var tempDirectory = new TemporaryDirectory();
690
- var projectPath = Path.Join(tempDirectory.DirectoryPath, "project.csproj");
691
- await File.WriteAllTextAsync(projectPath, """
692
- <Project Sdk="Microsoft.NET.Sdk">
693
- <PropertyGroup>
694
- <TargetFramework>net8.0</TargetFramework>
695
- </PropertyGroup>
696
- <ItemGroup>
697
- <PackageReference Include="CS-Script.Core" Version="1.3.1" />
698
- <PackageReference Include="Microsoft.CodeAnalysis.Common" Version="3.4.0" />
699
- <PackageReference Include="Microsoft.CodeAnalysis.Scripting.Common" Version="3.4.0" />
700
- </ItemGroup>
701
- </Project>
702
- """);
703
- await UpdateWorkerTestBase.MockNuGetPackagesInDirectory([
704
- // initial packages
705
- MockNuGetPackage.CreateSimplePackage("CS-Script.Core", "1.3.1", "net8.0", [(null, [("Microsoft.CodeAnalysis.Scripting.Common", "[3.4.0]")])]),
706
- MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.Scripting.Common", "3.4.0", "net8.0", [(null, [("Microsoft.CodeAnalysis.Common", "[3.4.0]")])]),
707
- MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.Common", "3.4.0", "net8.0"),
708
- // available packages
709
- MockNuGetPackage.CreateSimplePackage("CS-Script.Core", "2.0.0", "net8.0", [(null, [("Microsoft.CodeAnalysis.Scripting.Common", "[3.6.0]")])]),
710
- MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.Scripting.Common", "3.6.0", "net8.0", [(null, [("Microsoft.CodeAnalysis.Common", "[3.6.0]")])]),
711
- MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.Common", "3.6.0", "net8.0")
712
- ], tempDirectory.DirectoryPath);
713
-
714
- var dependencies = new[]
715
- {
716
- // Add comment about root and dependencies
717
- new Dependency("CS-Script.Core", "1.3.1", DependencyType.PackageReference),
718
- new Dependency("Microsoft.CodeAnalysis.Common", "3.4.0", DependencyType.PackageReference),
719
- new Dependency("Microsoft.CodeAnalysis.Scripting.Common", "3.4.0", DependencyType.PackageReference),
720
- }.ToImmutableArray();
721
- var update = new[]
722
- {
723
- new Dependency("CS-Script.Core", "2.0.0", DependencyType.PackageReference),
724
- }.ToImmutableArray();
725
-
726
- var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(
727
- tempDirectory.DirectoryPath,
728
- projectPath,
729
- "net8.0",
730
- dependencies,
731
- update,
732
- new ExperimentsManager() { InstallDotnetSdks = useExistingSdks },
733
- new TestLogger()
734
- );
735
- Assert.NotNull(resolvedDependencies);
736
- var actualResolvedDependencies = resolvedDependencies.Value.Select(d => $"{d.Name}/{d.Version}").ToArray();
737
- var expectedResolvedDependencies = new[]
738
- {
739
- "CS-Script.Core/2.0.0",
740
- "Microsoft.CodeAnalysis.Common/3.6.0",
741
- "Microsoft.CodeAnalysis.Scripting.Common/3.6.0",
742
- };
743
- AssertEx.Equal(expectedResolvedDependencies, actualResolvedDependencies);
744
- }
745
-
746
- // 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
747
- [Theory]
748
- [InlineData(true)]
749
- [InlineData(false)]
750
- public async Task DependencyConflictsCanBeResolvedNewUpdatingNonExistingDependency(bool useExistingSdks)
751
- {
752
- using var tempDirectory = new TemporaryDirectory();
753
- var projectPath = Path.Join(tempDirectory.DirectoryPath, "project.csproj");
754
- await File.WriteAllTextAsync(projectPath, """
755
- <Project Sdk="Microsoft.NET.Sdk">
756
- <PropertyGroup>
757
- <TargetFramework>net8.0</TargetFramework>
758
- </PropertyGroup>
759
- <ItemGroup>
760
- <PackageReference Include="Azure.Core" Version="1.21.0" />
761
- </ItemGroup>
762
- </Project>
763
- """);
764
- await UpdateWorkerTestBase.MockNuGetPackagesInDirectory([
765
- // initial packages
766
- MockNuGetPackage.CreateSimplePackage("Azure.Core", "1.21.0", "net8.0", [(null, [("Microsoft.Bcl.AsyncInterfaces", "[1.0.0]")])]),
767
- MockNuGetPackage.CreateSimplePackage("Microsoft.Bcl.AsyncInterfaces", "1.0.0", "net8.0"),
768
- // available packages
769
- MockNuGetPackage.CreateSimplePackage("Azure.Core", "1.22.0", "net8.0", [(null, [("Microsoft.Bcl.AsyncInterfaces", "[1.1.1]")])]),
770
- MockNuGetPackage.CreateSimplePackage("Microsoft.Bcl.AsyncInterfaces", "1.1.1", "net8.0")
771
- ], tempDirectory.DirectoryPath);
772
-
773
- var dependencies = new[]
774
- {
775
- new Dependency("Azure.Core", "1.21.0", DependencyType.PackageReference)
776
- }.ToImmutableArray();
777
- var update = new[]
778
- {
779
- new Dependency("Microsoft.Bcl.AsyncInterfaces", "1.1.1", DependencyType.Unknown)
780
- }.ToImmutableArray();
781
-
782
- var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(
783
- tempDirectory.DirectoryPath,
784
- projectPath,
785
- "net8.0",
786
- dependencies,
787
- update,
788
- new ExperimentsManager() { InstallDotnetSdks = useExistingSdks },
789
- new TestLogger()
790
- );
791
- Assert.NotNull(resolvedDependencies);
792
- var actualResolvedDependencies = resolvedDependencies.Value.Select(d => $"{d.Name}/{d.Version}").ToArray();
793
- var expectedResolvedDependencies = new[]
794
- {
795
- "Azure.Core/1.22.0",
796
- };
797
- AssertEx.Equal(expectedResolvedDependencies, actualResolvedDependencies);
798
- }
799
-
800
- // Adding a reference
801
- // 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
802
- // 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
803
- [Theory]
804
- [InlineData(true)]
805
- [InlineData(false)]
806
- public async Task DependencyConflictsCanBeResolvedNewUpdatingNonExistentDependencyAndKeepingReference(bool useExistingSdks)
807
- {
808
- using var tempDirectory = new TemporaryDirectory();
809
- var projectPath = Path.Join(tempDirectory.DirectoryPath, "project.csproj");
810
- await File.WriteAllTextAsync(projectPath, """
811
- <Project Sdk="Microsoft.NET.Sdk">
812
- <PropertyGroup>
813
- <TargetFramework>net8.0</TargetFramework>
814
- </PropertyGroup>
815
- <ItemGroup>
816
- <PackageReference Include="Newtonsoft.Json.Bson" Version="1.0.2" />
817
- </ItemGroup>
818
- </Project>
819
- """);
820
- await UpdateWorkerTestBase.MockNuGetPackagesInDirectory([
821
- // initial packages
822
- MockNuGetPackage.CreateSimplePackage("Newtonsoft.Json.Bson", "1.0.2", "net8.0", [(null, [("Newtonsoft.Json", "12.0.1")])]),
823
- MockNuGetPackage.CreateSimplePackage("Newtonsoft.Json", "12.0.1", "net8.0"),
824
- // available packages
825
- MockNuGetPackage.CreateSimplePackage("Newtonsoft.Json", "13.0.1", "net8.0")
826
- ], tempDirectory.DirectoryPath);
827
-
828
- var dependencies = new[]
829
- {
830
- new Dependency("Newtonsoft.Json.Bson", "1.0.2", DependencyType.PackageReference)
831
- }.ToImmutableArray();
832
- var update = new[]
833
- {
834
- new Dependency("Newtonsoft.Json", "13.0.1", DependencyType.Unknown)
835
- }.ToImmutableArray();
836
-
837
- var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(
838
- tempDirectory.DirectoryPath,
839
- projectPath,
840
- "net8.0",
841
- dependencies,
842
- update,
843
- new ExperimentsManager() { InstallDotnetSdks = useExistingSdks },
844
- new TestLogger()
845
- );
846
- Assert.NotNull(resolvedDependencies);
847
- var actualResolvedDependencies = resolvedDependencies.Value.Select(d => $"{d.Name}/{d.Version}").ToArray();
848
- var expectedResolvedDependencies = new[]
849
- {
850
- "Newtonsoft.Json.Bson/1.0.2",
851
- "Newtonsoft.Json/13.0.1",
852
- };
853
- AssertEx.Equal(expectedResolvedDependencies, actualResolvedDependencies);
854
- }
855
-
856
- // Updating unreferenced dependency
857
- // Root package (Microsoft.CodeAnalysis.Compilers) and its dependencies (Microsoft.CodeAnalysis.CSharp), (Microsoft.CodeAnalysis.VisualBasic) are all 4.9.2
858
- // 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
859
- // If Microsoft.CodeAnalysis.Common is updated to 4.10.0, everything else updates and Microsoft.CoseAnalysis.Common is not kept in the existing list
860
- [Theory]
861
- [InlineData(true)]
862
- [InlineData(false)]
863
- public async Task DependencyConflictsCanBeResolvedNewTransitiveDependencyNotExisting(bool useExistingSdks)
864
- {
865
- using var tempDirectory = new TemporaryDirectory();
866
- var projectPath = Path.Join(tempDirectory.DirectoryPath, "project.csproj");
867
- await File.WriteAllTextAsync(projectPath, """
868
- <Project Sdk="Microsoft.NET.Sdk">
869
- <PropertyGroup>
870
- <TargetFramework>net8.0</TargetFramework>
871
- </PropertyGroup>
872
- <ItemGroup>
873
- <PackageReference Include="Microsoft.CodeAnalysis.Compilers" Version="4.9.2" />
874
- <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.9.2" />
875
- <PackageReference Include="Microsoft.CodeAnalysis.VisualBasic" Version="4.9.2" />
876
- </ItemGroup>
877
- </Project>
878
- """);
879
- await UpdateWorkerTestBase.MockNuGetPackagesInDirectory([
880
- // initial packages
881
- MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.Compilers", "4.9.2", "net8.0", [(null, [("Microsoft.CodeAnalysis.Common", "[4.9.2]"), ("Microsoft.CodeAnalysis.CSharp", "[4.9.2]"), ("Microsoft.CodeAnalysis.VisualBasic", "[4.9.2]")])]),
882
- MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.Common", "4.9.2", "net8.0"),
883
- MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.CSharp", "4.9.2", "net8.0"),
884
- MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.VisualBasic", "4.9.2", "net8.0"),
885
- // available packages
886
- MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.Compilers", "4.10.0", "net8.0", [(null, [("Microsoft.CodeAnalysis.Common", "[4.10.0]"), ("Microsoft.CodeAnalysis.CSharp", "[4.10.0]"), ("Microsoft.CodeAnalysis.VisualBasic", "[4.10.0]")])]),
887
- MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.Common", "4.10.0", "net8.0"),
888
- MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.CSharp", "4.10.0", "net8.0"),
889
- MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.VisualBasic", "4.10.0", "net8.0")
890
- ], tempDirectory.DirectoryPath);
891
-
892
- var dependencies = new[]
893
- {
894
- new Dependency("Microsoft.CodeAnalysis.Compilers", "4.9.2", DependencyType.PackageReference),
895
- new Dependency("Microsoft.CodeAnalysis.CSharp", "4.9.2", DependencyType.PackageReference),
896
- new Dependency("Microsoft.CodeAnalysis.VisualBasic", "4.9.2", DependencyType.PackageReference)
897
- }.ToImmutableArray();
898
- var update = new[]
899
- {
900
- new Dependency("Microsoft.CodeAnalysis.Common", "4.10.0", DependencyType.PackageReference)
901
- }.ToImmutableArray();
902
-
903
- var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(
904
- tempDirectory.DirectoryPath,
905
- projectPath,
906
- "net8.0",
907
- dependencies,
908
- update,
909
- new ExperimentsManager() { InstallDotnetSdks = useExistingSdks },
910
- new TestLogger()
911
- );
912
- Assert.NotNull(resolvedDependencies);
913
- var actualResolvedDependencies = resolvedDependencies.Value.Select(d => $"{d.Name}/{d.Version}").ToArray();
914
- var expectedResolvedDependencies = new[]
915
- {
916
- "Microsoft.CodeAnalysis.Compilers/4.10.0",
917
- "Microsoft.CodeAnalysis.CSharp/4.10.0",
918
- "Microsoft.CodeAnalysis.VisualBasic/4.10.0",
919
- };
920
- AssertEx.Equal(expectedResolvedDependencies, actualResolvedDependencies);
921
- }
922
-
923
- // Updating referenced dependency
924
- // The same as previous test, but the transitive dependency (Microsoft.CodeAnalysis.Common) is in the existing list
925
- [Theory]
926
- [InlineData(true)]
927
- [InlineData(false)]
928
- public async Task DependencyConflictsCanBeResolvedNewSingleTransitiveDependencyExisting(bool useExistingSdks)
929
- {
930
- using var tempDirectory = new TemporaryDirectory();
931
- var projectPath = Path.Join(tempDirectory.DirectoryPath, "project.csproj");
932
- await File.WriteAllTextAsync(projectPath, """
933
- <Project Sdk="Microsoft.NET.Sdk">
934
- <PropertyGroup>
935
- <TargetFramework>net8.0</TargetFramework>
936
- </PropertyGroup>
937
- <ItemGroup>
938
- <PackageReference Include="Microsoft.CodeAnalysis.Compilers" Version="4.9.2" />
939
- <PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.9.2" />
940
- <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.9.2" />
941
- <PackageReference Include="Microsoft.CodeAnalysis.VisualBasic" Version="4.9.2" />
942
- </ItemGroup>
943
- </Project>
944
- """);
945
- await UpdateWorkerTestBase.MockNuGetPackagesInDirectory([
946
- // initial packages
947
- MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.Compilers", "4.9.2", "net8.0", [(null, [("Microsoft.CodeAnalysis.Common", "[4.9.2]"), ("Microsoft.CodeAnalysis.CSharp", "[4.9.2]"), ("Microsoft.CodeAnalysis.VisualBasic", "[4.9.2]")])]),
948
- MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.Common", "4.9.2", "net8.0"),
949
- MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.CSharp", "4.9.2", "net8.0"),
950
- MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.VisualBasic", "4.9.2", "net8.0"),
951
- // available packages
952
- MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.Compilers", "4.10.0", "net8.0", [(null, [("Microsoft.CodeAnalysis.Common", "[4.10.0]"), ("Microsoft.CodeAnalysis.CSharp", "[4.10.0]"), ("Microsoft.CodeAnalysis.VisualBasic", "[4.10.0]")])]),
953
- MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.Common", "4.10.0", "net8.0"),
954
- MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.CSharp", "4.10.0", "net8.0"),
955
- MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.VisualBasic", "4.10.0", "net8.0")
956
- ], tempDirectory.DirectoryPath);
957
-
958
- var dependencies = new[]
959
- {
960
- new Dependency("Microsoft.CodeAnalysis.Compilers", "4.9.2", DependencyType.PackageReference),
961
- new Dependency("Microsoft.CodeAnalysis.Common", "4.9.2", DependencyType.PackageReference),
962
- new Dependency("Microsoft.CodeAnalysis.CSharp", "4.9.2", DependencyType.PackageReference),
963
- new Dependency("Microsoft.CodeAnalysis.VisualBasic", "4.9.2", DependencyType.PackageReference)
964
- }.ToImmutableArray();
965
- var update = new[]
966
- {
967
- new Dependency("Microsoft.CodeAnalysis.Common", "4.10.0", DependencyType.PackageReference)
968
- }.ToImmutableArray();
969
-
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
- );
979
- Assert.NotNull(resolvedDependencies);
980
- var actualResolvedDependencies = resolvedDependencies.Value.Select(d => $"{d.Name}/{d.Version}").ToArray();
981
- var expectedResolvedDependencies = new[]
982
- {
983
- "Microsoft.CodeAnalysis.Compilers/4.10.0",
984
- "Microsoft.CodeAnalysis.Common/4.10.0",
985
- "Microsoft.CodeAnalysis.CSharp/4.10.0",
986
- "Microsoft.CodeAnalysis.VisualBasic/4.10.0",
987
- };
988
- AssertEx.Equal(expectedResolvedDependencies, actualResolvedDependencies);
989
- }
990
-
991
- // A combination of the third and fourth test, to measure efficiency of updating separate families
992
- // Keeping a dependency that was not included in the original list (Newtonsoft.Json)
993
- // Not keeping a dependency that was not included in the original list (Microsoft.CodeAnalysis.Common)
994
- [Theory]
995
- [InlineData(true)]
996
- [InlineData(false)]
997
- public async Task DependencyConflictsCanBeResolvedNewSelectiveAdditionPackages(bool useExistingSdks)
998
- {
999
- using var tempDirectory = new TemporaryDirectory();
1000
- var projectPath = Path.Join(tempDirectory.DirectoryPath, "project.csproj");
1001
- await File.WriteAllTextAsync(projectPath, """
1002
- <Project Sdk="Microsoft.NET.Sdk">
1003
- <PropertyGroup>
1004
- <TargetFramework>net8.0</TargetFramework>
1005
- </PropertyGroup>
1006
- <ItemGroup>
1007
- <PackageReference Include="Microsoft.CodeAnalysis.Compilers" Version="4.9.2" />
1008
- <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.9.2" />
1009
- <PackageReference Include="Microsoft.CodeAnalysis.VisualBasic" Version="4.9.2" />
1010
- <PackageReference Include="Newtonsoft.Json.Bson" Version="1.0.2" />
1011
- </ItemGroup>
1012
- </Project>
1013
- """);
1014
- await UpdateWorkerTestBase.MockNuGetPackagesInDirectory([
1015
- // initial packages
1016
- MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.Compilers", "4.9.2", "net8.0", [(null, [("Microsoft.CodeAnalysis.Common", "[4.9.2]"), ("Microsoft.CodeAnalysis.CSharp", "[4.9.2]"), ("Microsoft.CodeAnalysis.VisualBasic", "[4.9.2]")])]),
1017
- MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.Common", "4.9.2", "net8.0"),
1018
- MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.CSharp", "4.9.2", "net8.0"),
1019
- MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.VisualBasic", "4.9.2", "net8.0"),
1020
- MockNuGetPackage.CreateSimplePackage("Newtonsoft.Json.Bson", "1.0.2", "net8.0", [(null, [("Newtonsoft.Json", "13.0.1")])]),
1021
- MockNuGetPackage.CreateSimplePackage("Newtonsoft.Json", "13.0.1", "net8.0"),
1022
- // available packages
1023
- MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.Compilers", "4.10.0", "net8.0", [(null, [("Microsoft.CodeAnalysis.Common", "[4.10.0]"), ("Microsoft.CodeAnalysis.CSharp", "[4.10.0]"), ("Microsoft.CodeAnalysis.VisualBasic", "[4.10.0]")])]),
1024
- MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.Common", "4.10.0", "net8.0"),
1025
- MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.CSharp", "4.10.0", "net8.0"),
1026
- MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.VisualBasic", "4.10.0", "net8.0")
1027
- ], tempDirectory.DirectoryPath);
1028
-
1029
- var dependencies = new[]
1030
- {
1031
- new Dependency("Microsoft.CodeAnalysis.Compilers", "4.9.2", DependencyType.PackageReference),
1032
- new Dependency("Microsoft.CodeAnalysis.CSharp", "4.9.2", DependencyType.PackageReference),
1033
- new Dependency("Microsoft.CodeAnalysis.VisualBasic", "4.9.2", DependencyType.PackageReference),
1034
- new Dependency("Newtonsoft.Json.Bson", "1.0.2", DependencyType.PackageReference)
1035
- }.ToImmutableArray();
1036
- var update = new[]
1037
- {
1038
- new Dependency("Microsoft.CodeAnalysis.Common", "4.10.0", DependencyType.PackageReference),
1039
- new Dependency("Newtonsoft.Json", "13.0.1", DependencyType.Unknown)
1040
- }.ToImmutableArray();
1041
-
1042
- var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(
1043
- tempDirectory.DirectoryPath,
1044
- projectPath,
1045
- "net8.0",
1046
- dependencies,
1047
- update,
1048
- new ExperimentsManager() { InstallDotnetSdks = useExistingSdks },
1049
- new TestLogger()
1050
- );
1051
- Assert.NotNull(resolvedDependencies);
1052
- var actualResolvedDependencies = resolvedDependencies.Value.Select(d => $"{d.Name}/{d.Version}").ToArray();
1053
- var expectedResolvedDependencies = new[]
1054
- {
1055
- "Microsoft.CodeAnalysis.Compilers/4.10.0",
1056
- "Microsoft.CodeAnalysis.CSharp/4.10.0",
1057
- "Microsoft.CodeAnalysis.VisualBasic/4.10.0",
1058
- "Newtonsoft.Json.Bson/1.0.2",
1059
- "Newtonsoft.Json/13.0.1",
1060
- };
1061
- AssertEx.Equal(expectedResolvedDependencies, actualResolvedDependencies);
1062
- }
1063
-
1064
- // Two top level packages (Buildalyzer), (Microsoft.CodeAnalysis.CSharp.Scripting) that share a dependency (Microsoft.CodeAnalysis.Csharp)
1065
- // Updating ONE of the top level packages, which updates the dependencies and their other "parents"
1066
- // 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)
1067
- // 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)
1068
- // Updating Buildalyzer to 7.0.1 will update its transitive dependency (Microsoft.CodeAnalysis.Common) and then its transitive dependency's "family"
1069
- [Fact]
1070
- public async Task DependencyConflictsCanBeResolvedNewSharingDependency()
1071
- {
1072
- // arrange
1073
- using var tempDirectory = new TemporaryDirectory();
1074
- var projectPath = Path.Join(tempDirectory.DirectoryPath, "project.csproj");
1075
- await File.WriteAllTextAsync(projectPath, """
1076
- <Project Sdk="Microsoft.NET.Sdk">
1077
- <PropertyGroup>
1078
- <TargetFramework>net8.0</TargetFramework>
1079
- </PropertyGroup>
1080
- <ItemGroup>
1081
- <PackageReference Include="Buildalyzer" Version="6.0.4" />
1082
- <PackageReference Include="Microsoft.CodeAnalysis.Csharp.Scripting" Version="3.10.0" />
1083
- <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.10.0" />
1084
- <PackageReference Include="Microsoft.CodeAnalysis.Common" Version="3.10.0" />
1085
- </ItemGroup>
1086
- </Project>
1087
- """);
1088
-
1089
- var testPackages = new MockNuGetPackage[]
1090
- {
1091
- MockNuGetPackage.CreateSimplePackage("Buildalyzer", "6.0.4", "net8.0", [(null, [("Microsoft.CodeAnalysis.CSharp", "[3.10.0]")])]),
1092
- MockNuGetPackage.CreateSimplePackage("Buildalyzer", "7.0.1", "net8.0", [(null, [("Microsoft.CodeAnalysis.CSharp", "[4.0.1]")])]),
1093
-
1094
- MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.CSharp.Scripting", "3.10.0", "net8.0", [(null, [("Microsoft.CodeAnalysis.CSharp", "[3.10.0]")])]),
1095
- MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.CSharp.Scripting", "4.0.1", "net8.0", [(null, [("Microsoft.CodeAnalysis.CSharp", "[4.0.1]")])]),
1096
-
1097
- MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.CSharp", "3.10.0", "net8.0", [(null, [("Microsoft.CodeAnalysis.Common", "[3.10.0]")])]),
1098
- MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.CSharp", "4.0.1", "net8.0", [(null, [("Microsoft.CodeAnalysis.Common", "[4.0.1]")])]),
1099
-
1100
- MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.Common", "3.10.0", "net8.0"),
1101
- MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.Common", "4.0.1", "net8.0"),
1102
- };
1103
- await UpdateWorkerTestBase.MockNuGetPackagesInDirectory(testPackages, tempDirectory.DirectoryPath);
1104
-
1105
- var dependencies = new[]
1106
- {
1107
- new Dependency("Buildalyzer", "6.0.4", DependencyType.PackageReference),
1108
- new Dependency("Microsoft.CodeAnalysis.CSharp.Scripting", "3.10.0", DependencyType.PackageReference),
1109
- new Dependency("Microsoft.CodeAnalysis.CSharp", "3.10.0", DependencyType.PackageReference),
1110
- new Dependency("Microsoft.CodeAnalysis.Common", "3.10.0", DependencyType.PackageReference),
1111
- }.ToImmutableArray();
1112
- var update = new[]
1113
- {
1114
- new Dependency("Buildalyzer", "7.0.1", DependencyType.PackageReference),
1115
- }.ToImmutableArray();
1116
-
1117
- // act
1118
- var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(
1119
- tempDirectory.DirectoryPath,
1120
- projectPath,
1121
- "net8.0",
1122
- dependencies,
1123
- update,
1124
- new ExperimentsManager(),
1125
- new TestLogger()
1126
- );
1127
-
1128
- // assert
1129
- var expectedDependencies = new[]
1130
- {
1131
- "Buildalyzer/7.0.1",
1132
- "Microsoft.CodeAnalysis.CSharp.Scripting/4.0.1",
1133
- "Microsoft.CodeAnalysis.CSharp/4.0.1",
1134
- "Microsoft.CodeAnalysis.Common/4.0.1"
1135
- };
1136
- Assert.NotNull(resolvedDependencies);
1137
- var actualDependencies = resolvedDependencies.Value.Select(d => $"{d.Name}/{d.Version}").ToArray();
1138
- AssertEx.Equal(expectedDependencies, actualDependencies);
1139
- }
1140
-
1141
- // Updating two families at once to test efficiency
1142
- // 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)
1143
- // Second family: Updating the root package (Azure.Core) in the existing list will also need to update its dependency (Microsoft.Bcl.AsyncInterfaces)
1144
- [Theory]
1145
- [InlineData(true)]
1146
- [InlineData(false)]
1147
- public async Task DependencyConflictsCanBeResolvedNewUpdatingEntireFamily(bool useExistingSdks)
1148
- {
1149
- using var tempDirectory = new TemporaryDirectory();
1150
- var projectPath = Path.Join(tempDirectory.DirectoryPath, "project.csproj");
1151
- await File.WriteAllTextAsync(projectPath, """
1152
- <Project Sdk="Microsoft.NET.Sdk">
1153
- <PropertyGroup>
1154
- <TargetFramework>net8.0</TargetFramework>
1155
- </PropertyGroup>
1156
- <ItemGroup>
1157
- <PackageReference Include="System.Collections.Immutable" Version="7.0.0" />
1158
- <PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.8.0" />
1159
- <PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="1.0.0" />
1160
- <PackageReference Include="Azure.Core" Version="1.21.0" />
1161
- </ItemGroup>
1162
- </Project>
1163
- """);
1164
- await UpdateWorkerTestBase.MockNuGetPackagesInDirectory([
1165
- // initial packages
1166
- MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.CSharp.Scripting", "4.8.0", "net8.0", [(null, [("Microsoft.CodeAnalysis.CSharp", "[4.8.0]"), ("Microsoft.CodeAnalysis.Common", "[4.8.0]")])]),
1167
- MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.CSharp", "4.8.0", "net8.0", [(null, [("Microsoft.CodeAnalysis.Common", "[4.8.0]")])]),
1168
- MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.Common", "4.8.0", "net8.0", [(null, [("System.Collections.Immutable", "7.0.0")])]),
1169
- MockNuGetPackage.CreateSimplePackage("System.Collections.Immutable", "7.0.0", "net8.0"),
1170
- MockNuGetPackage.CreateSimplePackage("Azure.Core", "1.21.0", "net8.0", [(null, [("Microsoft.Bcl.AsyncInterfaces", "1.0.0")])]),
1171
- MockNuGetPackage.CreateSimplePackage("Microsoft.Bcl.AsyncInterfaces", "1.0.0", "net8.0"),
1172
- // available packages
1173
- MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.CSharp.Scripting", "4.10.0", "net8.0", [(null, [("Microsoft.CodeAnalysis.CSharp", "[4.10.0]"), ("Microsoft.CodeAnalysis.Common", "[4.10.0]")])]),
1174
- MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.CSharp", "4.10.0", "net8.0", [(null, [("Microsoft.CodeAnalysis.Common", "[4.10.0]")])]),
1175
- MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.Common", "4.10.0", "net8.0", [(null, [("System.Collections.Immutable", "8.0.0")])]),
1176
- MockNuGetPackage.CreateSimplePackage("System.Collections.Immutable", "8.0.0", "net8.0"),
1177
- MockNuGetPackage.CreateSimplePackage("Azure.Core", "1.22.0", "net8.0", [(null, [("Microsoft.Bcl.AsyncInterfaces", "1.1.1")])]),
1178
- MockNuGetPackage.CreateSimplePackage("Microsoft.Bcl.AsyncInterfaces", "1.1.1", "net8.0"),
1179
- ], tempDirectory.DirectoryPath);
1180
-
1181
- var dependencies = new[]
1182
- {
1183
- new Dependency("System.Collections.Immutable", "7.0.0", DependencyType.PackageReference),
1184
- new Dependency("Microsoft.CodeAnalysis.CSharp.Scripting", "4.8.0", DependencyType.PackageReference),
1185
- new Dependency("Microsoft.Bcl.AsyncInterfaces", "1.0.0", DependencyType.PackageReference),
1186
- new Dependency("Azure.Core", "1.21.0", DependencyType.PackageReference),
1187
- }.ToImmutableArray();
1188
- var update = new[]
1189
- {
1190
- new Dependency("Microsoft.CodeAnalysis.Common", "4.10.0", DependencyType.PackageReference),
1191
- new Dependency("Azure.Core", "1.22.0", DependencyType.PackageReference)
1192
- }.ToImmutableArray();
1193
-
1194
- var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(
1195
- tempDirectory.DirectoryPath,
1196
- projectPath,
1197
- "net8.0",
1198
- dependencies,
1199
- update,
1200
- new ExperimentsManager() { InstallDotnetSdks = useExistingSdks },
1201
- new TestLogger()
1202
- );
1203
- Assert.NotNull(resolvedDependencies);
1204
- var actualResolvedDependencies = resolvedDependencies.Value.Select(d => $"{d.Name}/{d.Version}").ToArray();
1205
- var expectedResolvedDependencies = new[]
1206
- {
1207
- "System.Collections.Immutable/8.0.0",
1208
- "Microsoft.CodeAnalysis.CSharp.Scripting/4.10.0",
1209
- "Microsoft.Bcl.AsyncInterfaces/1.1.1",
1210
- "Azure.Core/1.22.0",
1211
- };
1212
- AssertEx.Equal(expectedResolvedDependencies, actualResolvedDependencies);
1213
- }
1214
-
1215
- // Similar to the last test, except Microsoft.CodeAnalysis.Common is in the existing list
1216
- [Theory]
1217
- [InlineData(true)]
1218
- [InlineData(false)]
1219
- public async Task DependencyConflictsCanBeResolvedNewUpdatingTopLevelAndDependency(bool useExistingSdks)
1220
- {
1221
- using var tempDirectory = new TemporaryDirectory();
1222
- var projectPath = Path.Join(tempDirectory.DirectoryPath, "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.Scripting" Version="4.8.0" />
1231
- <PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.8.0" />
1232
- <PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="1.0.0" />
1233
- <PackageReference Include="Azure.Core" Version="1.21.0" />
1234
- </ItemGroup>
1235
- </Project>
1236
- """);
1237
- await UpdateWorkerTestBase.MockNuGetPackagesInDirectory([
1238
- // initial packages
1239
- MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.CSharp.Scripting", "4.8.0", "net8.0", [(null, [("Microsoft.CodeAnalysis.CSharp", "[4.8.0]"), ("Microsoft.CodeAnalysis.Common", "[4.8.0]")])]),
1240
- MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.CSharp", "4.8.0", "net8.0", [(null, [("Microsoft.CodeAnalysis.Common", "[4.8.0]")])]),
1241
- MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.Common", "4.8.0", "net8.0", [(null, [("System.Collections.Immutable", "7.0.0")])]),
1242
- MockNuGetPackage.CreateSimplePackage("System.Collections.Immutable", "7.0.0", "net8.0"),
1243
- MockNuGetPackage.CreateSimplePackage("Azure.Core", "1.21.0", "net8.0", [(null, [("Microsoft.Bcl.AsyncInterfaces", "1.0.0")])]),
1244
- MockNuGetPackage.CreateSimplePackage("Microsoft.Bcl.AsyncInterfaces", "1.0.0", "net8.0"),
1245
- // available packages
1246
- MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.CSharp.Scripting", "4.10.0", "net8.0", [(null, [("Microsoft.CodeAnalysis.CSharp", "[4.10.0]"), ("Microsoft.CodeAnalysis.Common", "[4.10.0]")])]),
1247
- MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.CSharp", "4.10.0", "net8.0", [(null, [("Microsoft.CodeAnalysis.Common", "[4.10.0]")])]),
1248
- MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.Common", "4.10.0", "net8.0", [(null, [("System.Collections.Immutable", "8.0.0")])]),
1249
- MockNuGetPackage.CreateSimplePackage("System.Collections.Immutable", "8.0.0", "net8.0"),
1250
- MockNuGetPackage.CreateSimplePackage("Azure.Core", "1.22.0", "net8.0", [(null, [("Microsoft.Bcl.AsyncInterfaces", "1.1.1")])]),
1251
- MockNuGetPackage.CreateSimplePackage("Microsoft.Bcl.AsyncInterfaces", "1.1.1", "net8.0"),
1252
- ], tempDirectory.DirectoryPath);
1253
-
1254
- var dependencies = new[]
1255
- {
1256
- new Dependency("System.Collections.Immutable", "7.0.0", DependencyType.PackageReference),
1257
- new Dependency("Microsoft.CodeAnalysis.CSharp.Scripting", "4.8.0", DependencyType.PackageReference),
1258
- new Dependency("Microsoft.CodeAnalysis.Common", "4.8.0", DependencyType.PackageReference),
1259
- new Dependency("Microsoft.Bcl.AsyncInterfaces", "1.0.0", DependencyType.Unknown),
1260
- new Dependency("Azure.Core", "1.21.0", DependencyType.PackageReference),
1261
-
1262
- }.ToImmutableArray();
1263
- var update = new[]
1264
- {
1265
- new Dependency("Microsoft.CodeAnalysis.Common", "4.10.0", DependencyType.PackageReference),
1266
- new Dependency("Azure.Core", "1.22.0", DependencyType.PackageReference)
1267
- }.ToImmutableArray();
1268
-
1269
- var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(
1270
- tempDirectory.DirectoryPath,
1271
- projectPath,
1272
- "net8.0",
1273
- dependencies,
1274
- update,
1275
- new ExperimentsManager() { InstallDotnetSdks = useExistingSdks },
1276
- new TestLogger()
1277
- );
1278
- Assert.NotNull(resolvedDependencies);
1279
- var actualResolvedDependencies = resolvedDependencies.Value.Select(d => $"{d.Name}/{d.Version}").ToArray();
1280
- var expectedResolvedDependencies = new[]
1281
- {
1282
- "System.Collections.Immutable/8.0.0",
1283
- "Microsoft.CodeAnalysis.CSharp.Scripting/4.10.0",
1284
- "Microsoft.CodeAnalysis.Common/4.10.0",
1285
- "Microsoft.Bcl.AsyncInterfaces/1.1.1",
1286
- "Azure.Core/1.22.0"
1287
- };
1288
- AssertEx.Equal(expectedResolvedDependencies, actualResolvedDependencies);
1289
- }
1290
-
1291
- // Out of scope test: AutoMapper.Extensions.Microsoft.DependencyInjection's versions are not yet compatible
1292
- // To update root package (AutoMapper.Collection) to 10.0.0, its dependency (AutoMapper) needs to update to 13.0.0.
1293
- // However, there is no higher version of AutoMapper's other "parent" (AutoMapper.Extensions.Microsoft.DependencyInjection) that is compatible with the new version
1294
- [Theory]
1295
- [InlineData(true)]
1296
- [InlineData(false)]
1297
- public async Task DependencyConflictsCanBeResolvedNewOutOfScope(bool useExistingSdks)
1298
- {
1299
- using var tempDirectory = new TemporaryDirectory();
1300
- var projectPath = Path.Join(tempDirectory.DirectoryPath, "project.csproj");
1301
- await File.WriteAllTextAsync(projectPath, """
1302
- <Project Sdk="Microsoft.NET.Sdk">
1303
- <PropertyGroup>
1304
- <TargetFramework>net8.0</TargetFramework>
1305
- </PropertyGroup>
1306
- <ItemGroup>
1307
- <PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
1308
- <PackageReference Include="AutoMapper" Version="12.0.1" />
1309
- <PackageReference Include="AutoMapper.Collection" Version="9.0.0" />
1310
- </ItemGroup>
1311
- </Project>
1312
- """);
1313
- await UpdateWorkerTestBase.MockNuGetPackagesInDirectory([
1314
- MockNuGetPackage.CreateSimplePackage("AutoMapper.Extensions.Microsoft.DependencyInjection", "12.0.1", "net8.0", [(null, [("AutoMapper", "[12.0.1]")])]),
1315
- MockNuGetPackage.CreateSimplePackage("AutoMapper", "12.0.1", "net8.0"),
1316
- MockNuGetPackage.CreateSimplePackage("AutoMapper", "13.0.1", "net8.0"),
1317
- MockNuGetPackage.CreateSimplePackage("AutoMapper.Collection", "9.0.0", "net8.0", [(null, [("AutoMapper", "[12.0.0, 13.0.0)")])]),
1318
- MockNuGetPackage.CreateSimplePackage("AutoMapper.Collection", "10.0.0", "net8.0", [(null, [("AutoMapper", "[13.0.0, 14.0.0)")])])
1319
- ], tempDirectory.DirectoryPath);
1320
-
1321
- var dependencies = new[]
1322
- {
1323
- new Dependency("AutoMapper.Extensions.Microsoft.DependencyInjection", "12.0.1", DependencyType.PackageReference),
1324
- new Dependency("AutoMapper", "12.0.1", DependencyType.PackageReference),
1325
- new Dependency("AutoMapper.Collection", "9.0.0", DependencyType.PackageReference)
1326
- }.ToImmutableArray();
1327
- var update = new[]
1328
- {
1329
- new Dependency("AutoMapper.Collection", "10.0.0", DependencyType.PackageReference)
1330
- }.ToImmutableArray();
1331
-
1332
- var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(
1333
- tempDirectory.DirectoryPath,
1334
- projectPath,
1335
- "net8.0",
1336
- dependencies,
1337
- update,
1338
- new ExperimentsManager() { InstallDotnetSdks = useExistingSdks },
1339
- new TestLogger()
1340
- );
1341
- Assert.NotNull(resolvedDependencies);
1342
- var actualResolvedDependencies = resolvedDependencies.Value.Select(d => $"{d.Name}/{d.Version}").ToArray();
1343
- var expectedResolvedDependencies = new[]
1344
- {
1345
- "AutoMapper.Extensions.Microsoft.DependencyInjection/12.0.1",
1346
- "AutoMapper/12.0.1",
1347
- "AutoMapper.Collection/9.0.0",
1348
- };
1349
- AssertEx.Equal(expectedResolvedDependencies, actualResolvedDependencies);
1350
- }
1351
-
1352
- // Two dependencies (Microsoft.Extensions.Caching.Memory), (Microsoft.EntityFrameworkCore.Analyzers) used by the same parent (Microsoft.EntityFrameworkCore), updating one of the dependencies
1353
- [Theory]
1354
- [InlineData(true)]
1355
- [InlineData(false)]
1356
- public async Task DependencyConflictsCanBeResolvedNewTwoDependenciesShareSameParent(bool useExistingSdks)
1357
- {
1358
- using var tempDirectory = new TemporaryDirectory();
1359
- var projectPath = Path.Join(tempDirectory.DirectoryPath, "project.csproj");
1360
- await File.WriteAllTextAsync(projectPath, """
1361
- <Project Sdk="Microsoft.NET.Sdk">
1362
- <PropertyGroup>
1363
- <TargetFramework>net8.0</TargetFramework>
1364
- </PropertyGroup>
1365
- <ItemGroup>
1366
- <PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.11" />
1367
- <PackageReference Include="Microsoft.EntityFrameworkCore.Analyzers" Version="7.0.11" />
1368
- </ItemGroup>
1369
- </Project>
1370
- """);
1371
- await UpdateWorkerTestBase.MockNuGetPackagesInDirectory([
1372
- // initial packages
1373
- MockNuGetPackage.CreateSimplePackage("Microsoft.EntityFrameworkCore", "7.0.11", "net8.0", [(null, [("Microsoft.EntityFrameworkCore.Analyzers", "7.0.11"), ("Microsoft.Extensions.Caching.Memory", "[7.0.0]")])]),
1374
- MockNuGetPackage.CreateSimplePackage("Microsoft.EntityFrameworkCore.Analyzers", "7.0.11", "net8.0"),
1375
- MockNuGetPackage.CreateSimplePackage("Microsoft.Extensions.Caching.Memory", "7.0.0", "net8.0"),
1376
- // available packages
1377
- MockNuGetPackage.CreateSimplePackage("Microsoft.EntityFrameworkCore", "8.0.0", "net8.0", [(null, [("Microsoft.EntityFrameworkCore.Analyzers", "8.0.0"), ("Microsoft.Extensions.Caching.Memory", "[8.0.0]")])]),
1378
- MockNuGetPackage.CreateSimplePackage("Microsoft.EntityFrameworkCore.Analyzers", "8.0.0", "net8.0"),
1379
- MockNuGetPackage.CreateSimplePackage("Microsoft.Extensions.Caching.Memory", "8.0.0", "net8.0"),
1380
- ], tempDirectory.DirectoryPath);
1381
-
1382
- var dependencies = new[]
1383
- {
1384
- new Dependency("Microsoft.EntityFrameworkCore", "7.0.11", DependencyType.PackageReference),
1385
- new Dependency("Microsoft.EntityFrameworkCore.Analyzers", "7.0.11", DependencyType.PackageReference)
1386
- }.ToImmutableArray();
1387
- var update = new[]
1388
- {
1389
- new Dependency("Microsoft.Extensions.Caching.Memory", "8.0.0", DependencyType.PackageReference)
1390
- }.ToImmutableArray();
1391
-
1392
- var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(
1393
- tempDirectory.DirectoryPath,
1394
- projectPath,
1395
- "net8.0",
1396
- dependencies,
1397
- update,
1398
- new ExperimentsManager() { InstallDotnetSdks = useExistingSdks },
1399
- new TestLogger()
1400
- );
1401
- Assert.NotNull(resolvedDependencies);
1402
- var actualResolvedDependencies = resolvedDependencies.Value.Select(d => $"{d.Name}/{d.Version}").ToArray();
1403
- var expectedResolvedDependencies = new[]
1404
- {
1405
- "Microsoft.EntityFrameworkCore/8.0.0",
1406
- "Microsoft.EntityFrameworkCore.Analyzers/8.0.0",
1407
- };
1408
- AssertEx.Equal(expectedResolvedDependencies, actualResolvedDependencies);
1409
- }
1410
-
1411
- // Updating referenced package
1412
- // 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
1413
- [Theory]
1414
- [InlineData(true)]
1415
- [InlineData(false)]
1416
- public async Task DependencyConflictsCanBeResolvedNewFamilyOfFourExisting(bool useExistingSdks)
1417
- {
1418
- using var tempDirectory = new TemporaryDirectory();
1419
- var projectPath = Path.Join(tempDirectory.DirectoryPath, "project.csproj");
1420
- await File.WriteAllTextAsync(projectPath, """
1421
- <Project Sdk="Microsoft.NET.Sdk">
1422
- <PropertyGroup>
1423
- <TargetFramework>net8.0</TargetFramework>
1424
- </PropertyGroup>
1425
- <ItemGroup>
1426
- <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.0" />
1427
- <PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="7.0.0" />
1428
- <PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.0" />
1429
- <PackageReference Include="Microsoft.EntityFrameworkCore.Analyzers" Version="7.0.0" />
1430
- </ItemGroup>
1431
- </Project>
1432
- """);
1433
- await UpdateWorkerTestBase.MockNuGetPackagesInDirectory([
1434
- // initial packages
1435
- MockNuGetPackage.CreateSimplePackage("Microsoft.EntityFrameworkCore.Design", "7.0.0", "net8.0", [(null, [("Microsoft.EntityFrameworkCore.Relational", "[7.0.0]")])]),
1436
- MockNuGetPackage.CreateSimplePackage("Microsoft.EntityFrameworkCore.Relational", "7.0.0", "net8.0", [(null, [("Microsoft.EntityFrameworkCore", "[7.0.0]")])]),
1437
- MockNuGetPackage.CreateSimplePackage("Microsoft.EntityFrameworkCore", "7.0.0", "net8.0", [(null, [("Microsoft.EntityFrameworkCore.Analyzers", "[7.0.0]")])]),
1438
- MockNuGetPackage.CreateSimplePackage("Microsoft.EntityFrameworkCore.Analyzers", "7.0.0", "net8.0"),
1439
- // available packages
1440
- MockNuGetPackage.CreateSimplePackage("Microsoft.EntityFrameworkCore.Analyzers", "8.0.0", "net8.0")
1441
- ], tempDirectory.DirectoryPath);
1442
-
1443
- var dependencies = new[]
1444
- {
1445
- new Dependency("Microsoft.EntityFrameworkCore.Design", "7.0.0", DependencyType.PackageReference),
1446
- new Dependency("Microsoft.EntityFrameworkCore.Relational", "7.0.0", DependencyType.PackageReference),
1447
- new Dependency("Microsoft.EntityFrameworkCore", "7.0.0", DependencyType.PackageReference),
1448
- new Dependency("Microsoft.EntityFrameworkCore.Analyzers", "7.0.0", DependencyType.PackageReference)
1449
- }.ToImmutableArray();
1450
- var update = new[]
1451
- {
1452
- new Dependency("Microsoft.EntityFrameworkCore.Analyzers", "8.0.0", DependencyType.PackageReference)
1453
- }.ToImmutableArray();
1454
-
1455
- var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(
1456
- tempDirectory.DirectoryPath,
1457
- projectPath,
1458
- "net8.0",
1459
- dependencies,
1460
- update,
1461
- new ExperimentsManager() { InstallDotnetSdks = useExistingSdks },
1462
- new TestLogger()
1463
- );
1464
- Assert.NotNull(resolvedDependencies);
1465
- var actualResolvedDependencies = resolvedDependencies.Value.Select(d => $"{d.Name}/{d.Version}").ToArray();
1466
- var expectedResolvedDependencies = new[]
1467
- {
1468
- "Microsoft.EntityFrameworkCore.Design/7.0.0",
1469
- "Microsoft.EntityFrameworkCore.Relational/7.0.0",
1470
- "Microsoft.EntityFrameworkCore/7.0.0",
1471
- "Microsoft.EntityFrameworkCore.Analyzers/8.0.0",
1472
- };
1473
- AssertEx.Equal(expectedResolvedDependencies, actualResolvedDependencies);
1474
- }
1475
-
1476
- // Updating unreferenced package
1477
- // 4 dependency chain to be updated, dependency to be updated is not in the existing list, so its family will all be updated
1478
- [Theory]
1479
- [InlineData(true)]
1480
- [InlineData(false)]
1481
- public async Task DependencyConflictsCanBeResolvedNewFamilyOfFourNotInExisting(bool useExistingSdks)
1482
- {
1483
- using var tempDirectory = new TemporaryDirectory();
1484
- var projectPath = Path.Join(tempDirectory.DirectoryPath, "project.csproj");
1485
- await File.WriteAllTextAsync(projectPath, """
1486
- <Project Sdk="Microsoft.NET.Sdk">
1487
- <PropertyGroup>
1488
- <TargetFramework>net8.0</TargetFramework>
1489
- </PropertyGroup>
1490
- <ItemGroup>
1491
- <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.0" />
1492
- <PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="7.0.0" />
1493
- <PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.0" />
1494
- </ItemGroup>
1495
- </Project>
1496
- """);
1497
- await UpdateWorkerTestBase.MockNuGetPackagesInDirectory([
1498
- // initial packages
1499
- MockNuGetPackage.CreateSimplePackage("Microsoft.EntityFrameworkCore.Design", "7.0.0", "net8.0", [(null, [("Microsoft.EntityFrameworkCore.Relational", "[7.0.0]")])]),
1500
- MockNuGetPackage.CreateSimplePackage("Microsoft.EntityFrameworkCore.Relational", "7.0.0", "net8.0", [(null, [("Microsoft.EntityFrameworkCore", "[7.0.0]")])]),
1501
- MockNuGetPackage.CreateSimplePackage("Microsoft.EntityFrameworkCore", "7.0.0", "net8.0", [(null, [("Microsoft.EntityFrameworkCore.Analyzers", "[7.0.0]")])]),
1502
- MockNuGetPackage.CreateSimplePackage("Microsoft.EntityFrameworkCore.Analyzers", "7.0.0", "net8.0"),
1503
- // available packages
1504
- MockNuGetPackage.CreateSimplePackage("Microsoft.EntityFrameworkCore.Design", "8.0.0", "net8.0", [(null, [("Microsoft.EntityFrameworkCore.Relational", "[8.0.0]")])]),
1505
- MockNuGetPackage.CreateSimplePackage("Microsoft.EntityFrameworkCore.Relational", "8.0.0", "net8.0", [(null, [("Microsoft.EntityFrameworkCore", "[8.0.0]")])]),
1506
- MockNuGetPackage.CreateSimplePackage("Microsoft.EntityFrameworkCore", "8.0.0", "net8.0", [(null, [("Microsoft.EntityFrameworkCore.Analyzers", "[8.0.0]")])]),
1507
- MockNuGetPackage.CreateSimplePackage("Microsoft.EntityFrameworkCore.Analyzers", "8.0.0", "net8.0")
1508
- ], tempDirectory.DirectoryPath);
1509
-
1510
- var dependencies = new[]
1511
- {
1512
- new Dependency("Microsoft.EntityFrameworkCore.Design", "7.0.0", DependencyType.PackageReference),
1513
- new Dependency("Microsoft.EntityFrameworkCore.Relational", "7.0.0", DependencyType.PackageReference),
1514
- new Dependency("Microsoft.EntityFrameworkCore", "7.0.0", DependencyType.PackageReference),
1515
- }.ToImmutableArray();
1516
- var update = new[]
1517
- {
1518
- new Dependency("Microsoft.EntityFrameworkCore.Analyzers", "8.0.0", DependencyType.PackageReference)
1519
- }.ToImmutableArray();
1520
-
1521
- var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(
1522
- tempDirectory.DirectoryPath,
1523
- projectPath,
1524
- "net8.0",
1525
- dependencies,
1526
- update,
1527
- new ExperimentsManager() { InstallDotnetSdks = useExistingSdks },
1528
- new TestLogger()
1529
- );
1530
- Assert.NotNull(resolvedDependencies);
1531
- var actualResolvedDependencies = resolvedDependencies.Value.Select(d => $"{d.Name}/{d.Version}").ToArray();
1532
- var expectedResolvedDependencies = new[]
1533
- {
1534
- "Microsoft.EntityFrameworkCore.Design/8.0.0",
1535
- "Microsoft.EntityFrameworkCore.Relational/8.0.0",
1536
- "Microsoft.EntityFrameworkCore/8.0.0",
1537
- };
1538
- AssertEx.Equal(expectedResolvedDependencies, actualResolvedDependencies);
1539
- }
1540
-
1541
- // Updating a referenced transitive dependency
1542
- // 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
1543
- [Theory]
1544
- [InlineData(true)]
1545
- [InlineData(false)]
1546
- public async Task DependencyConflictsCanBeResolvedNewFamilyOfFourSpecificExisting(bool useExistingSdks)
1547
- {
1548
- using var tempDirectory = new TemporaryDirectory();
1549
- var projectPath = Path.Join(tempDirectory.DirectoryPath, "project.csproj");
1550
- await File.WriteAllTextAsync(projectPath, """
1551
- <Project Sdk="Microsoft.NET.Sdk">
1552
- <PropertyGroup>
1553
- <TargetFramework>net8.0</TargetFramework>
1554
- </PropertyGroup>
1555
- <ItemGroup>
1556
- <PackageReference Include="System.Collections.Immutable" Version="7.0.0" />
1557
- <PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.8.0" />
1558
- <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.8.0" />
1559
- <PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.8.0" />
1560
- </ItemGroup>
1561
- </Project>
1562
- """);
1563
- await UpdateWorkerTestBase.MockNuGetPackagesInDirectory([
1564
- // initial packages
1565
- MockNuGetPackage.CreateSimplePackage("System.Collections.Immutable", "7.0.0", "net8.0"),
1566
- MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.CSharp.Workspaces", "4.8.0", "net8.0", [(null, [("Microsoft.CodeAnalysis.CSharp", "[4.8.0]"), ("Microsoft.CodeAnalysis.Common", "[4.8.0]")])]),
1567
- MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.CSharp", "4.8.0", "net8.0", [(null, [("Microsoft.CodeAnalysis.Common", "[4.8.0]")])]),
1568
- MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.Common", "4.8.0", "net8.0", [(null, [("System.Collections.Immutable", "7.0.0")])]),
1569
- // available packages
1570
- MockNuGetPackage.CreateSimplePackage("System.Collections.Immutable", "8.0.0", "net8.0")
1571
- ], tempDirectory.DirectoryPath);
1572
-
1573
- var dependencies = new[]
1574
- {
1575
- new Dependency("System.Collections.Immutable", "7.0.0", DependencyType.PackageReference),
1576
- new Dependency("Microsoft.CodeAnalysis.CSharp.Workspaces", "4.8.0", DependencyType.PackageReference),
1577
- new Dependency("Microsoft.CodeAnalysis.CSharp", "4.8.0", DependencyType.PackageReference),
1578
- new Dependency("Microsoft.CodeAnalysis.Common", "4.8.0", DependencyType.PackageReference),
1579
- }.ToImmutableArray();
1580
- var update = new[]
1581
- {
1582
- new Dependency("System.Collections.Immutable", "8.0.0", DependencyType.PackageReference),
1583
- }.ToImmutableArray();
1584
-
1585
- var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(
1586
- tempDirectory.DirectoryPath,
1587
- projectPath,
1588
- "net8.0",
1589
- dependencies,
1590
- update,
1591
- new ExperimentsManager() { InstallDotnetSdks = useExistingSdks },
1592
- new TestLogger()
1593
- );
1594
- Assert.NotNull(resolvedDependencies);
1595
- var actualResolvedDependencies = resolvedDependencies.Value.Select(d => $"{d.Name}/{d.Version}").ToArray();
1596
- var expectedResolvedDependencies = new[]
1597
- {
1598
- "System.Collections.Immutable/8.0.0",
1599
- "Microsoft.CodeAnalysis.CSharp.Workspaces/4.8.0",
1600
- "Microsoft.CodeAnalysis.CSharp/4.8.0",
1601
- "Microsoft.CodeAnalysis.Common/4.8.0",
1602
- };
1603
- AssertEx.Equal(expectedResolvedDependencies, actualResolvedDependencies);
1604
- }
1605
-
1606
- // Similar to the last test, with the "grandchild" (System.Collections.Immutable) not in the existing list
1607
- [Theory]
1608
- [InlineData(true)]
1609
- [InlineData(false)]
1610
- public async Task DependencyConflictsCanBeResolvedNewFamilyOfFourSpecificNotInExisting(bool useExistingSdks)
1611
- {
1612
- using var tempDirectory = new TemporaryDirectory();
1613
- var projectPath = Path.Join(tempDirectory.DirectoryPath, "project.csproj");
1614
- await File.WriteAllTextAsync(projectPath, """
1615
- <Project Sdk="Microsoft.NET.Sdk">
1616
- <PropertyGroup>
1617
- <TargetFramework>net8.0</TargetFramework>
1618
- </PropertyGroup>
1619
- <ItemGroup>
1620
- <PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.8.0" />
1621
- <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.8.0" />
1622
- <PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.8.0" />
1623
- </ItemGroup>
1624
- </Project>
1625
- """);
1626
- await UpdateWorkerTestBase.MockNuGetPackagesInDirectory([
1627
- // initial packages
1628
- MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.CSharp.Workspaces", "4.8.0", "net8.0", [(null, [("Microsoft.CodeAnalysis.CSharp", "[4.8.0]"), ("Microsoft.CodeAnalysis.Common", "[4.8.0]")])]),
1629
- MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.CSharp", "4.8.0", "net8.0", [(null, [("Microsoft.CodeAnalysis.Common", "[4.8.0]")])]),
1630
- MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.Common", "4.8.0", "net8.0", [(null, [("System.Collections.Immutable", "[7.0.0]")])]),
1631
- MockNuGetPackage.CreateSimplePackage("System.Collections.Immutable", "7.0.0", "net8.0"),
1632
- // available packages
1633
- MockNuGetPackage.CreateSimplePackage("System.Collections.Immutable", "8.0.0", "net8.0"),
1634
- MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.CSharp.Workspaces", "4.9.2", "net8.0", [(null, [("Microsoft.CodeAnalysis.CSharp", "[4.9.2]"), ("Microsoft.CodeAnalysis.Common", "[4.9.2]")])]),
1635
- MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.CSharp", "4.9.2", "net8.0", [(null, [("Microsoft.CodeAnalysis.Common", "[4.9.2]")])]),
1636
- MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.Common", "4.9.2", "net8.0", [(null, [("System.Collections.Immutable", "[8.0.0]")])]),
1637
- ], tempDirectory.DirectoryPath);
1638
-
1639
- var dependencies = new[]
1640
- {
1641
- new Dependency("Microsoft.CodeAnalysis.CSharp.Workspaces", "4.8.0", DependencyType.PackageReference),
1642
- new Dependency("Microsoft.CodeAnalysis.CSharp", "4.8.0", DependencyType.PackageReference),
1643
- new Dependency("Microsoft.CodeAnalysis.Common", "4.8.0", DependencyType.PackageReference),
1644
- }.ToImmutableArray();
1645
- var update = new[]
1646
- {
1647
- new Dependency("System.Collections.Immutable", "8.0.0", DependencyType.PackageReference),
1648
- }.ToImmutableArray();
1649
-
1650
- var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(
1651
- tempDirectory.DirectoryPath,
1652
- projectPath,
1653
- "net8.0",
1654
- dependencies,
1655
- update,
1656
- new ExperimentsManager() { InstallDotnetSdks = useExistingSdks },
1657
- new TestLogger()
1658
- );
1659
- Assert.NotNull(resolvedDependencies);
1660
- var actualResolvedDependencies = resolvedDependencies.Value.Select(d => $"{d.Name}/{d.Version}").ToArray();
1661
- var expectedResolvedDependencies = new[]
1662
- {
1663
- "Microsoft.CodeAnalysis.CSharp.Workspaces/4.9.2",
1664
- "Microsoft.CodeAnalysis.CSharp/4.9.2",
1665
- "Microsoft.CodeAnalysis.Common/4.9.2",
1666
- };
1667
- AssertEx.Equal(expectedResolvedDependencies, actualResolvedDependencies);
1668
- }
1669
-
1670
- [Fact(Timeout = 120_000)] // 2m
1671
- public async Task DependencyConflictsCanBeResolved_TopLevelDependencyHasNewerVersionsThatDoNotPullUpTransitive()
1672
- {
1673
- using var tempDirectory = new TemporaryDirectory();
1674
- var projectPath = Path.Join(tempDirectory.DirectoryPath, "project.csproj");
1675
- await File.WriteAllTextAsync(projectPath, """
1676
- <Project Sdk="Microsoft.NET.Sdk">
1677
- <PropertyGroup>
1678
- <TargetFramework>net8.0</TargetFramework>
1679
- </PropertyGroup>
1680
- <ItemGroup>
1681
- <PackageReference Include="Top.Level.Package" Version="1.41.0" />
1682
- </ItemGroup>
1683
- </Project>
1684
- """);
1685
- await UpdateWorkerTestBase.MockNuGetPackagesInDirectory([
1686
- // initial packages
1687
- MockNuGetPackage.CreateSimplePackage("Top.Level.Package", "1.41.0", "net8.0", [(null, [("Transitive.Package", "6.0.0")])]),
1688
- MockNuGetPackage.CreateSimplePackage("Transitive.Package", "6.0.0", "net8.0"),
1689
- // available packages
1690
- MockNuGetPackage.CreateSimplePackage("Top.Level.Package", "1.45.0", "net8.0", [(null, [("Transitive.Package", "6.0.0")])]),
1691
- MockNuGetPackage.CreateSimplePackage("Transitive.Package", "8.0.5", "net8.0"),
1692
- ], tempDirectory.DirectoryPath);
1693
-
1694
- var dependencies = new[]
1695
- {
1696
- new Dependency("Top.Level.Package", "1.41.0", DependencyType.PackageReference),
1697
- }.ToImmutableArray();
1698
- var update = new[]
1699
- {
1700
- new Dependency("Transitive.Package", "8.0.5", DependencyType.PackageReference),
1701
- }.ToImmutableArray();
1702
-
1703
- var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(
1704
- tempDirectory.DirectoryPath,
1705
- projectPath,
1706
- "net8.0",
1707
- dependencies,
1708
- update,
1709
- new ExperimentsManager() { InstallDotnetSdks = true },
1710
- new TestLogger()
1711
- );
1712
- Assert.NotNull(resolvedDependencies);
1713
- var actualResolvedDependencies = resolvedDependencies.Value.Select(d => $"{d.Name}/{d.Version}").ToArray();
1714
- var expectedResolvedDependencies = new[]
1715
- {
1716
- "Top.Level.Package/1.41.0",
1717
- "Transitive.Package/8.0.5",
1718
- };
1719
- AssertEx.Equal(expectedResolvedDependencies, actualResolvedDependencies);
1720
- }
1721
-
1722
- #endregion
1723
-
1724
681
  [Theory]
1725
682
  [MemberData(nameof(GenerateErrorFromToolOutputTestData))]
1726
683
  public async Task GenerateErrorFromToolOutput(string output, JobErrorBase? expectedError)
@@ -1821,6 +778,14 @@ public class MSBuildHelperTests : TestBase
1821
778
  new PrivateSourceBadResponse(["http://localhost/test-feed"]),
1822
779
  ];
1823
780
 
781
+ yield return
782
+ [
783
+ // output
784
+ " The HTTP request to 'GET some-source' has timed out after 100000ms.",
785
+ // expectedError
786
+ new PrivateSourceTimedOut("some-source"),
787
+ ];
788
+
1824
789
  yield return
1825
790
  [
1826
791
  // output
@@ -1869,6 +834,14 @@ public class MSBuildHelperTests : TestBase
1869
834
  new DependencyNotFound("Some.Package"),
1870
835
  ];
1871
836
 
837
+ yield return
838
+ [
839
+ // output
840
+ "Unable to resolve dependency 'Some.Package'. Source(s) used: 'nuget.org'.",
841
+ // expectedError
842
+ new DependencyNotFound("Some.Package"),
843
+ ];
844
+
1872
845
  yield return
1873
846
  [
1874
847
  // output