dependabot-nuget 0.280.0 → 0.282.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/helpers/lib/NuGetUpdater/Directory.Common.props +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/AnalyzeCommand.cs +4 -6
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/DiscoverCommand.cs +4 -6
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/FrameworkCheckCommand.cs +4 -7
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/RunCommand.cs +4 -6
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/UpdateCommand.cs +3 -5
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Analyze.cs +0 -3
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.FrameworkCheck.cs +0 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Run.cs +1 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Update.cs +3 -6
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/AnalyzeWorker.cs +9 -9
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/CompatabilityChecker.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/DependencyFinder.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/NuGetContext.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/VersionFinder.cs +5 -5
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DirectoryPackagesPropsDiscovery.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DiscoveryWorker.cs +3 -3
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DotNetToolsJsonDiscovery.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/GlobalJsonDiscovery.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/PackagesConfigDiscovery.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/SdkProjectDiscovery.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/ErrorType.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/DotNetToolsJsonBuildFile.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/GlobalJsonBuildFile.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/JsonBuildFile.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/FrameworkChecker/CompatabilityChecker.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/RunWorker.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/BindingRedirectManager.cs +16 -6
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/DotNetToolsJsonUpdater.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/GlobalJsonUpdater.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/LockFileUpdater.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/{SdkPackageUpdater.cs → PackageReferenceUpdater.cs} +97 -37
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/PackagesConfigUpdater.cs +26 -10
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/UpdaterWorker.cs +12 -4
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/ConsoleLogger.cs +9 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/DependencyConflictResolver.cs +14 -16
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/ILogger.cs +6 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/MSBuildHelper.cs +25 -23
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/NuGetHelper.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Analyze/AnalyzeWorkerTestBase.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Analyze/AnalyzeWorkerTests.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Analyze/CompatibilityCheckerTests.cs +7 -7
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/DependencySolverEnvironment.cs +12 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTestBase.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Files/DotNetToolsJsonBuildFileTests.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Files/GlobalJsonBuildFileTests.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/FrameworkChecker/CompatibilityCheckerFacts.cs +4 -4
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/RunWorkerTests.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/TestLogger.cs +11 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/ExpectedUpdateOperationResult.cs +8 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/PackagesConfigUpdaterTests.cs +3 -3
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTestBase.cs +14 -6
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.DirsProj.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.Mixed.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/{UpdateWorkerTests.Sdk.cs → UpdateWorkerTests.PackageReference.cs} +200 -23
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackagesConfig.cs +221 -8
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/MSBuildHelperTests.cs +56 -18
- data/lib/dependabot/nuget/file_fetcher.rb +58 -21
- data/lib/dependabot/nuget/file_updater.rb +1 -0
- data/lib/dependabot/nuget/native_helpers.rb +10 -16
- metadata +19 -15
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/Logger.cs +0 -21
@@ -10,7 +10,7 @@ namespace NuGetUpdater.Core.Test.Update;
|
|
10
10
|
|
11
11
|
public partial class UpdateWorkerTests
|
12
12
|
{
|
13
|
-
public class
|
13
|
+
public class PackageReference : UpdateWorkerTestBase
|
14
14
|
{
|
15
15
|
[Theory]
|
16
16
|
[InlineData("net472")]
|
@@ -54,12 +54,12 @@ public partial class UpdateWorkerTests
|
|
54
54
|
}
|
55
55
|
|
56
56
|
[Theory]
|
57
|
-
[InlineData(
|
58
|
-
[InlineData(
|
59
|
-
public async Task UpdateVersionChildElement_InProjectFile_ForPackageReferenceIncludeTheory(
|
57
|
+
[InlineData(true)]
|
58
|
+
[InlineData(false)]
|
59
|
+
public async Task UpdateVersionChildElement_InProjectFile_ForPackageReferenceIncludeTheory(bool useDependencySolver)
|
60
60
|
{
|
61
61
|
// update Some.Package from 9.0.1 to 13.0.1
|
62
|
-
using var
|
62
|
+
using var _ = new DependencySolverEnvironment(useDependencySolver);
|
63
63
|
await TestUpdateForProject("Some.Package", "9.0.1", "13.0.1",
|
64
64
|
packages:
|
65
65
|
[
|
@@ -95,11 +95,72 @@ public partial class UpdateWorkerTests
|
|
95
95
|
);
|
96
96
|
}
|
97
97
|
|
98
|
+
[Theory]
|
99
|
+
[InlineData(true)]
|
100
|
+
[InlineData(false)]
|
101
|
+
public async Task PeerDependenciesAreUpdatedEvenWhenNotExplicit(bool useDependencySolver)
|
102
|
+
{
|
103
|
+
using var _ = new DependencySolverEnvironment(useDependencySolver);
|
104
|
+
await TestUpdateForProject("Some.Package", "1.0.0", "2.0.0",
|
105
|
+
packages:
|
106
|
+
[
|
107
|
+
MockNuGetPackage.CreateSimplePackage("Some.Package", "1.0.0", "net8.0", [(null, [("Transitive.Package", "[1.0.0]")])]),
|
108
|
+
MockNuGetPackage.CreateSimplePackage("Some.Package", "2.0.0", "net8.0", [(null, [("Transitive.Package", "[2.0.0]")])]),
|
109
|
+
MockNuGetPackage.CreateSimplePackage("Transitive.Package", "1.0.0", "net8.0"),
|
110
|
+
MockNuGetPackage.CreateSimplePackage("Transitive.Package", "2.0.0", "net8.0"),
|
111
|
+
],
|
112
|
+
projectFile: ("a/a.csproj", """
|
113
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
114
|
+
<PropertyGroup>
|
115
|
+
<TargetFramework>net8.0</TargetFramework>
|
116
|
+
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
|
117
|
+
</PropertyGroup>
|
118
|
+
<ItemGroup>
|
119
|
+
<PackageReference Include="Some.Package" />
|
120
|
+
</ItemGroup>
|
121
|
+
</Project>
|
122
|
+
"""),
|
123
|
+
additionalFiles:
|
124
|
+
[
|
125
|
+
("Directory.Packages.props", """
|
126
|
+
<Project>
|
127
|
+
<ItemGroup>
|
128
|
+
<PackageVersion Include="Some.Package" Version="1.0.0" />
|
129
|
+
<PackageVersion Include="Transitive.Package" Version="1.0.0" />
|
130
|
+
</ItemGroup>
|
131
|
+
</Project>
|
132
|
+
""")
|
133
|
+
],
|
134
|
+
expectedProjectContents: """
|
135
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
136
|
+
<PropertyGroup>
|
137
|
+
<TargetFramework>net8.0</TargetFramework>
|
138
|
+
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
|
139
|
+
</PropertyGroup>
|
140
|
+
<ItemGroup>
|
141
|
+
<PackageReference Include="Some.Package" />
|
142
|
+
</ItemGroup>
|
143
|
+
</Project>
|
144
|
+
""",
|
145
|
+
additionalFilesExpected:
|
146
|
+
[
|
147
|
+
("Directory.Packages.props", """
|
148
|
+
<Project>
|
149
|
+
<ItemGroup>
|
150
|
+
<PackageVersion Include="Some.Package" Version="2.0.0" />
|
151
|
+
<PackageVersion Include="Transitive.Package" Version="2.0.0" />
|
152
|
+
</ItemGroup>
|
153
|
+
</Project>
|
154
|
+
""")
|
155
|
+
]
|
156
|
+
);
|
157
|
+
}
|
158
|
+
|
98
159
|
[Fact]
|
99
160
|
public async Task CallingResolveDependencyConflictsNew()
|
100
161
|
{
|
101
162
|
// update Microsoft.CodeAnalysis.Common from 4.9.2 to 4.10.0
|
102
|
-
using var
|
163
|
+
using var _ = new DependencySolverEnvironment();
|
103
164
|
await TestUpdateForProject("Microsoft.CodeAnalysis.Common", "4.9.2", "4.10.0",
|
104
165
|
// initial
|
105
166
|
projectContents: $"""
|
@@ -454,7 +515,7 @@ public partial class UpdateWorkerTests
|
|
454
515
|
//
|
455
516
|
// do the update
|
456
517
|
//
|
457
|
-
UpdaterWorker worker = new(new(
|
518
|
+
UpdaterWorker worker = new(new TestLogger());
|
458
519
|
await worker.RunAsync(tempDirectory.DirectoryPath, projectPath, "Some.Package", "1.0.0", "1.1.0", isTransitive: false);
|
459
520
|
|
460
521
|
//
|
@@ -535,11 +596,11 @@ public partial class UpdateWorkerTests
|
|
535
596
|
}
|
536
597
|
|
537
598
|
[Theory]
|
538
|
-
[InlineData(
|
539
|
-
[InlineData(
|
540
|
-
public async Task AddPackageReference_InProjectFile_ForTransientDependency(
|
599
|
+
[InlineData(true)]
|
600
|
+
[InlineData(false)]
|
601
|
+
public async Task AddPackageReference_InProjectFile_ForTransientDependency(bool useDependencySolver)
|
541
602
|
{
|
542
|
-
using var
|
603
|
+
using var _ = new DependencySolverEnvironment(useDependencySolver);
|
543
604
|
// add transient package Some.Transient.Dependency from 5.0.1 to 5.0.2
|
544
605
|
await TestUpdateForProject("Some.Transient.Dependency", "5.0.1", "5.0.2", isTransitive: true,
|
545
606
|
packages:
|
@@ -2914,12 +2975,51 @@ public partial class UpdateWorkerTests
|
|
2914
2975
|
);
|
2915
2976
|
}
|
2916
2977
|
|
2978
|
+
[Fact]
|
2979
|
+
public async Task UpdatingTransitiveDependencyWithNewSolverCanUpdateJustTheTopLevelPackage()
|
2980
|
+
{
|
2981
|
+
// we've been asked to explicitly update a transitive dependency, but we can solve it by updating the top-level package instead
|
2982
|
+
using var _ = new DependencySolverEnvironment();
|
2983
|
+
await TestUpdateForProject("Transitive.Package", "1.0.0", "2.0.0",
|
2984
|
+
isTransitive: true,
|
2985
|
+
packages:
|
2986
|
+
[
|
2987
|
+
MockNuGetPackage.CreateSimplePackage("Some.Package", "1.0.0", "net8.0", [("net8.0", [("Transitive.Package", "[1.0.0]")])]),
|
2988
|
+
MockNuGetPackage.CreateSimplePackage("Some.Package", "2.0.0", "net8.0", [("net8.0", [("Transitive.Package", "[2.0.0]")])]),
|
2989
|
+
MockNuGetPackage.CreateSimplePackage("Transitive.Package", "1.0.0", "net8.0"),
|
2990
|
+
MockNuGetPackage.CreateSimplePackage("Transitive.Package", "2.0.0", "net8.0"),
|
2991
|
+
],
|
2992
|
+
projectContents: """
|
2993
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
2994
|
+
<PropertyGroup>
|
2995
|
+
<TargetFramework>net8.0</TargetFramework>
|
2996
|
+
<ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>
|
2997
|
+
</PropertyGroup>
|
2998
|
+
<ItemGroup>
|
2999
|
+
<PackageReference Include="Some.Package" Version="1.0.0" />
|
3000
|
+
</ItemGroup>
|
3001
|
+
</Project>
|
3002
|
+
""",
|
3003
|
+
expectedProjectContents: """
|
3004
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
3005
|
+
<PropertyGroup>
|
3006
|
+
<TargetFramework>net8.0</TargetFramework>
|
3007
|
+
<ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>
|
3008
|
+
</PropertyGroup>
|
3009
|
+
<ItemGroup>
|
3010
|
+
<PackageReference Include="Some.Package" Version="2.0.0" />
|
3011
|
+
</ItemGroup>
|
3012
|
+
</Project>
|
3013
|
+
"""
|
3014
|
+
);
|
3015
|
+
}
|
3016
|
+
|
2917
3017
|
[Theory]
|
2918
|
-
[InlineData(
|
2919
|
-
[InlineData(
|
2920
|
-
public async Task NoChange_IfThereAreIncoherentVersions(
|
3018
|
+
[InlineData(true)]
|
3019
|
+
[InlineData(false)]
|
3020
|
+
public async Task NoChange_IfThereAreIncoherentVersions(bool useDependencySolver)
|
2921
3021
|
{
|
2922
|
-
using var
|
3022
|
+
using var _ = new DependencySolverEnvironment(useDependencySolver);
|
2923
3023
|
|
2924
3024
|
// trying to update `Transitive.Dependency` to 1.1.0 would normally pull `Some.Package` from 1.0.0 to 1.1.0,
|
2925
3025
|
// but the TFM doesn't allow it
|
@@ -2968,6 +3068,42 @@ public partial class UpdateWorkerTests
|
|
2968
3068
|
);
|
2969
3069
|
}
|
2970
3070
|
|
3071
|
+
[Fact]
|
3072
|
+
public async Task ProcessingProjectWithWorkloadReferencesDoesNotFail()
|
3073
|
+
{
|
3074
|
+
// enumerating the build files will fail if the Aspire workload is not installed; this test ensures we can
|
3075
|
+
// still process the update
|
3076
|
+
await TestUpdateForProject("Some.Package", "7.0.1", "13.0.1",
|
3077
|
+
packages:
|
3078
|
+
[
|
3079
|
+
MockNuGetPackage.CreateSimplePackage("Some.Package", "7.0.1", "net8.0"),
|
3080
|
+
MockNuGetPackage.CreateSimplePackage("Some.Package", "13.0.1", "net8.0"),
|
3081
|
+
],
|
3082
|
+
projectContents: """
|
3083
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
3084
|
+
<PropertyGroup>
|
3085
|
+
<TargetFrameworks>net8.0-ios;net8.0-android;net8.0-macos;net8.0-maccatalyst;</TargetFrameworks>
|
3086
|
+
<IsAspireHost>true</IsAspireHost>
|
3087
|
+
</PropertyGroup>
|
3088
|
+
<ItemGroup>
|
3089
|
+
<PackageReference Include="Some.Package" Version="7.0.1" />
|
3090
|
+
</ItemGroup>
|
3091
|
+
</Project>
|
3092
|
+
""",
|
3093
|
+
expectedProjectContents: """
|
3094
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
3095
|
+
<PropertyGroup>
|
3096
|
+
<TargetFrameworks>net8.0-ios;net8.0-android;net8.0-macos;net8.0-maccatalyst;</TargetFrameworks>
|
3097
|
+
<IsAspireHost>true</IsAspireHost>
|
3098
|
+
</PropertyGroup>
|
3099
|
+
<ItemGroup>
|
3100
|
+
<PackageReference Include="Some.Package" Version="13.0.1" />
|
3101
|
+
</ItemGroup>
|
3102
|
+
</Project>
|
3103
|
+
"""
|
3104
|
+
);
|
3105
|
+
}
|
3106
|
+
|
2971
3107
|
[Fact]
|
2972
3108
|
public async Task ProcessingProjectWithAspireDoesNotFailEvenThoughWorkloadIsNotInstalled()
|
2973
3109
|
{
|
@@ -3005,11 +3141,11 @@ public partial class UpdateWorkerTests
|
|
3005
3141
|
}
|
3006
3142
|
|
3007
3143
|
[Theory]
|
3008
|
-
[InlineData(
|
3009
|
-
[InlineData(
|
3010
|
-
public async Task UnresolvablePropertyDoesNotStopOtherUpdates(
|
3144
|
+
[InlineData(true)]
|
3145
|
+
[InlineData(false)]
|
3146
|
+
public async Task UnresolvablePropertyDoesNotStopOtherUpdates(bool useDependencySolver)
|
3011
3147
|
{
|
3012
|
-
using var
|
3148
|
+
using var _ = new DependencySolverEnvironment(useDependencySolver);
|
3013
3149
|
|
3014
3150
|
// the property `$(SomeUnresolvableProperty)` cannot be resolved
|
3015
3151
|
await TestUpdateForProject("Some.Package", "7.0.1", "13.0.1",
|
@@ -3044,12 +3180,53 @@ public partial class UpdateWorkerTests
|
|
3044
3180
|
);
|
3045
3181
|
}
|
3046
3182
|
|
3183
|
+
|
3184
|
+
[Theory]
|
3185
|
+
[InlineData(true)]
|
3186
|
+
[InlineData(false)]
|
3187
|
+
public async Task ProjectWithWorkloadsShouldNotFail(bool useDependencySolver)
|
3188
|
+
{
|
3189
|
+
using var _ = new DependencySolverEnvironment(useDependencySolver);
|
3190
|
+
|
3191
|
+
// the property `$(SomeUnresolvableProperty)` cannot be resolved
|
3192
|
+
await TestUpdateForProject("Some.Package", "7.0.1", "13.0.1",
|
3193
|
+
packages:
|
3194
|
+
[
|
3195
|
+
MockNuGetPackage.CreateSimplePackage("Some.Package", "7.0.1", "net8.0"),
|
3196
|
+
MockNuGetPackage.CreateSimplePackage("Some.Package", "13.0.1", "net8.0"),
|
3197
|
+
MockNuGetPackage.CreateSimplePackage("Some.Other.Package", "1.0.0", "net8.0"),
|
3198
|
+
],
|
3199
|
+
projectContents: """
|
3200
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
3201
|
+
<PropertyGroup>
|
3202
|
+
<TargetFrameworks>net8.0;net8.0-ios;net8.0-android;net8.0-macos;net8.0-maccatalyst</TargetFrameworks>
|
3203
|
+
</PropertyGroup>
|
3204
|
+
<ItemGroup>
|
3205
|
+
<PackageReference Include="Some.Other.Package" Version="$(SomeUnresolvableProperty)" />
|
3206
|
+
<PackageReference Include="Some.Package" Version="7.0.1" />
|
3207
|
+
</ItemGroup>
|
3208
|
+
</Project>
|
3209
|
+
""",
|
3210
|
+
expectedProjectContents: """
|
3211
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
3212
|
+
<PropertyGroup>
|
3213
|
+
<TargetFrameworks>net8.0;net8.0-ios;net8.0-android;net8.0-macos;net8.0-maccatalyst</TargetFrameworks>
|
3214
|
+
</PropertyGroup>
|
3215
|
+
<ItemGroup>
|
3216
|
+
<PackageReference Include="Some.Other.Package" Version="$(SomeUnresolvableProperty)" />
|
3217
|
+
<PackageReference Include="Some.Package" Version="13.0.1" />
|
3218
|
+
</ItemGroup>
|
3219
|
+
</Project>
|
3220
|
+
"""
|
3221
|
+
);
|
3222
|
+
}
|
3223
|
+
|
3047
3224
|
[Theory]
|
3048
|
-
[InlineData(
|
3049
|
-
[InlineData(
|
3050
|
-
public async Task UpdatingPackageAlsoUpdatesAnythingWithADependencyOnTheUpdatedPackage(
|
3225
|
+
[InlineData(true)]
|
3226
|
+
[InlineData(false)]
|
3227
|
+
public async Task UpdatingPackageAlsoUpdatesAnythingWithADependencyOnTheUpdatedPackage(bool useDependencySolver)
|
3051
3228
|
{
|
3052
|
-
using var
|
3229
|
+
using var _ = new DependencySolverEnvironment(useDependencySolver);
|
3053
3230
|
|
3054
3231
|
// updating Some.Package from 3.3.30 requires that Some.Package.Extensions also be updated
|
3055
3232
|
await TestUpdateForProject("Some.Package", "3.3.30", "3.4.3",
|
data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackagesConfig.cs
CHANGED
@@ -4,6 +4,7 @@ using System.Text.Json;
|
|
4
4
|
|
5
5
|
using NuGet;
|
6
6
|
|
7
|
+
using NuGetUpdater.Core.Test.Updater;
|
7
8
|
using NuGetUpdater.Core.Updater;
|
8
9
|
|
9
10
|
using Xunit;
|
@@ -307,6 +308,83 @@ public partial class UpdateWorkerTests
|
|
307
308
|
);
|
308
309
|
}
|
309
310
|
|
311
|
+
[Fact]
|
312
|
+
public async Task UpdatePackageWithTargetsFileWhereProjectUsesBackslashes()
|
313
|
+
{
|
314
|
+
// The bug that caused this test to be written did not repro on Windows. The reason is that the packages
|
315
|
+
// directory is determined to be `..\packages`, but the backslash was retained. Later when packages were
|
316
|
+
// restored to that location, a directory with a name like `..?packages` would be created which didn't
|
317
|
+
// match the <Import> element's path of "..\packages\..." that had no `Condition="Exists(path)"` attribute.
|
318
|
+
await TestUpdateForProject("Some.Package", "1.0.0", "2.0.0",
|
319
|
+
packages:
|
320
|
+
[
|
321
|
+
MockNuGetPackage.CreateSimplePackage("Some.Package", "1.0.0", "net45"),
|
322
|
+
MockNuGetPackage.CreateSimplePackage("Some.Package", "2.0.0", "net45"),
|
323
|
+
new MockNuGetPackage("Package.With.Targets", "1.0.0", Files: [("build/SomeFile.targets", Encoding.UTF8.GetBytes("<Project />"))]),
|
324
|
+
],
|
325
|
+
// existing
|
326
|
+
projectFile: ("src/project.csproj", """
|
327
|
+
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
328
|
+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
329
|
+
<PropertyGroup>
|
330
|
+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
331
|
+
</PropertyGroup>
|
332
|
+
<ItemGroup>
|
333
|
+
<None Include="packages.config" />
|
334
|
+
</ItemGroup>
|
335
|
+
<ItemGroup>
|
336
|
+
<Reference Include="Some.Package">
|
337
|
+
<HintPath>..\packages\Some.Package.1.0.0\lib\net45\Some.Package.dll</HintPath>
|
338
|
+
<Private>True</Private>
|
339
|
+
</Reference>
|
340
|
+
</ItemGroup>
|
341
|
+
<Import Project="..\packages\Package.With.Targets.1.0.0\build\SomeFile.targets" />
|
342
|
+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
343
|
+
</Project>
|
344
|
+
"""),
|
345
|
+
additionalFiles:
|
346
|
+
[
|
347
|
+
("src/packages.config", """
|
348
|
+
<?xml version="1.0" encoding="utf-8"?>
|
349
|
+
<packages>
|
350
|
+
<package id="Package.With.Targets" version="1.0.0" targetFramework="net45" />
|
351
|
+
<package id="Some.Package" version="1.0.0" targetFramework="net45" />
|
352
|
+
</packages>
|
353
|
+
""")
|
354
|
+
],
|
355
|
+
// expected
|
356
|
+
expectedProjectContents: """
|
357
|
+
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
358
|
+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
359
|
+
<PropertyGroup>
|
360
|
+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
361
|
+
</PropertyGroup>
|
362
|
+
<ItemGroup>
|
363
|
+
<None Include="packages.config" />
|
364
|
+
</ItemGroup>
|
365
|
+
<ItemGroup>
|
366
|
+
<Reference Include="Some.Package">
|
367
|
+
<HintPath>..\packages\Some.Package.2.0.0\lib\net45\Some.Package.dll</HintPath>
|
368
|
+
<Private>True</Private>
|
369
|
+
</Reference>
|
370
|
+
</ItemGroup>
|
371
|
+
<Import Project="..\packages\Package.With.Targets.1.0.0\build\SomeFile.targets" />
|
372
|
+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
373
|
+
</Project>
|
374
|
+
""",
|
375
|
+
additionalFilesExpected:
|
376
|
+
[
|
377
|
+
("src/packages.config", """
|
378
|
+
<?xml version="1.0" encoding="utf-8"?>
|
379
|
+
<packages>
|
380
|
+
<package id="Package.With.Targets" version="1.0.0" targetFramework="net45" />
|
381
|
+
<package id="Some.Package" version="2.0.0" targetFramework="net45" />
|
382
|
+
</packages>
|
383
|
+
""")
|
384
|
+
]
|
385
|
+
);
|
386
|
+
}
|
387
|
+
|
310
388
|
[Fact]
|
311
389
|
public async Task UpdateSingleDependencyInPackagesConfigButNotToLatest()
|
312
390
|
{
|
@@ -603,8 +681,12 @@ public partial class UpdateWorkerTests
|
|
603
681
|
);
|
604
682
|
}
|
605
683
|
|
606
|
-
|
607
|
-
|
684
|
+
// the xml can take various shapes and they're all formatted, so we need very specific values here
|
685
|
+
[Theory]
|
686
|
+
[InlineData("<Content Include=\"web.config\" />")]
|
687
|
+
[InlineData("<Content Include=\"web.config\">\n </Content>")]
|
688
|
+
[InlineData("<Content Include=\"web.config\">\n <SubType>Designer</SubType>\n </Content>")]
|
689
|
+
public async Task UpdateBindingRedirectInWebConfig(string webConfigXml)
|
608
690
|
{
|
609
691
|
await TestUpdateForProject("Some.Package", "7.0.1", "13.0.1",
|
610
692
|
packages:
|
@@ -612,7 +694,7 @@ public partial class UpdateWorkerTests
|
|
612
694
|
MockNuGetPackage.CreatePackageWithAssembly("Some.Package", "7.0.1", "net45", "7.0.0.0"),
|
613
695
|
MockNuGetPackage.CreatePackageWithAssembly("Some.Package", "13.0.1", "net45", "13.0.0.0"),
|
614
696
|
],
|
615
|
-
projectContents: """
|
697
|
+
projectContents: $$"""
|
616
698
|
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
617
699
|
<PropertyGroup>
|
618
700
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
@@ -669,7 +751,7 @@ public partial class UpdateWorkerTests
|
|
669
751
|
</ItemGroup>
|
670
752
|
<ItemGroup>
|
671
753
|
<None Include="packages.config" />
|
672
|
-
|
754
|
+
{{webConfigXml}}
|
673
755
|
<Content Include="web.Debug.config">
|
674
756
|
<DependentUpon>web.config</DependentUpon>
|
675
757
|
</Content>
|
@@ -711,7 +793,7 @@ public partial class UpdateWorkerTests
|
|
711
793
|
</configuration>
|
712
794
|
""")
|
713
795
|
],
|
714
|
-
expectedProjectContents: """
|
796
|
+
expectedProjectContents: $$"""
|
715
797
|
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
716
798
|
<PropertyGroup>
|
717
799
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
@@ -768,7 +850,7 @@ public partial class UpdateWorkerTests
|
|
768
850
|
</ItemGroup>
|
769
851
|
<ItemGroup>
|
770
852
|
<None Include="packages.config" />
|
771
|
-
|
853
|
+
{{webConfigXml}}
|
772
854
|
<Content Include="web.Debug.config">
|
773
855
|
<DependentUpon>web.config</DependentUpon>
|
774
856
|
</Content>
|
@@ -2100,7 +2182,7 @@ public partial class UpdateWorkerTests
|
|
2100
2182
|
await MockNuGetPackagesInDirectory(packages, Path.Combine(temporaryDirectory.DirectoryPath, "packages"));
|
2101
2183
|
var resultOutputPath = Path.Combine(temporaryDirectory.DirectoryPath, "result.json");
|
2102
2184
|
|
2103
|
-
var worker = new UpdaterWorker(new
|
2185
|
+
var worker = new UpdaterWorker(new TestLogger());
|
2104
2186
|
await worker.RunAsync(temporaryDirectory.DirectoryPath, "project.csproj", "Some.Package", "1.0.0", "1.1.0", isTransitive: false, resultOutputPath: resultOutputPath);
|
2105
2187
|
|
2106
2188
|
var resultContents = await File.ReadAllTextAsync(resultOutputPath);
|
@@ -2190,6 +2272,137 @@ public partial class UpdateWorkerTests
|
|
2190
2272
|
);
|
2191
2273
|
}
|
2192
2274
|
|
2275
|
+
[Fact]
|
2276
|
+
public async Task ReportsUnexpectedResponseFromNuGetServer()
|
2277
|
+
{
|
2278
|
+
static (int, string) TestHttpHandler(string uriString)
|
2279
|
+
{
|
2280
|
+
var uri = new Uri(uriString, UriKind.Absolute);
|
2281
|
+
var baseUrl = $"{uri.Scheme}://{uri.Host}:{uri.Port}";
|
2282
|
+
return uri.PathAndQuery switch
|
2283
|
+
{
|
2284
|
+
// initial and search query are good, update should be possible...
|
2285
|
+
"/index.json" => (200, $$"""
|
2286
|
+
{
|
2287
|
+
"version": "3.0.0",
|
2288
|
+
"resources": [
|
2289
|
+
{
|
2290
|
+
"@id": "{{baseUrl}}/download",
|
2291
|
+
"@type": "PackageBaseAddress/3.0.0"
|
2292
|
+
},
|
2293
|
+
{
|
2294
|
+
"@id": "{{baseUrl}}/query",
|
2295
|
+
"@type": "SearchQueryService"
|
2296
|
+
},
|
2297
|
+
{
|
2298
|
+
"@id": "{{baseUrl}}/registrations",
|
2299
|
+
"@type": "RegistrationsBaseUrl"
|
2300
|
+
}
|
2301
|
+
]
|
2302
|
+
}
|
2303
|
+
"""),
|
2304
|
+
"/registrations/some.package/index.json" => (200, $$"""
|
2305
|
+
{
|
2306
|
+
"count": 1,
|
2307
|
+
"items": [
|
2308
|
+
{
|
2309
|
+
"lower": "1.0.0",
|
2310
|
+
"upper": "1.1.0",
|
2311
|
+
"items": [
|
2312
|
+
{
|
2313
|
+
"catalogEntry": {
|
2314
|
+
"id": "Some.Package",
|
2315
|
+
"listed": true,
|
2316
|
+
"version": "1.0.0"
|
2317
|
+
},
|
2318
|
+
"packageContent": "{{baseUrl}}/download/some.package/1.0.0/some.package.1.0.0.nupkg",
|
2319
|
+
},
|
2320
|
+
{
|
2321
|
+
"catalogEntry": {
|
2322
|
+
"id": "Some.Package",
|
2323
|
+
"listed": true,
|
2324
|
+
"version": "1.1.0"
|
2325
|
+
},
|
2326
|
+
"packageContent": "{{baseUrl}}/download/some.package/1.1.0/some.package.1.1.0.nupkg",
|
2327
|
+
}
|
2328
|
+
]
|
2329
|
+
}
|
2330
|
+
]
|
2331
|
+
}
|
2332
|
+
"""),
|
2333
|
+
// ...but all other calls to the server fail
|
2334
|
+
_ => (500, "{}"),
|
2335
|
+
};
|
2336
|
+
}
|
2337
|
+
using var http = TestHttpServer.CreateTestStringServer(TestHttpHandler);
|
2338
|
+
await TestUpdateForProject("Some.Package", "1.0.0", "1.1.0",
|
2339
|
+
// existing
|
2340
|
+
projectContents: """
|
2341
|
+
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
2342
|
+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
2343
|
+
<PropertyGroup>
|
2344
|
+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
2345
|
+
</PropertyGroup>
|
2346
|
+
<ItemGroup>
|
2347
|
+
<None Include="packages.config" />
|
2348
|
+
</ItemGroup>
|
2349
|
+
<ItemGroup>
|
2350
|
+
<Reference Include="Some.Package, Version=1.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed">
|
2351
|
+
<HintPath>packages\Some.Package.1.0.0\lib\net45\Some.Package.dll</HintPath>
|
2352
|
+
<Private>True</Private>
|
2353
|
+
</Reference>
|
2354
|
+
</ItemGroup>
|
2355
|
+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
2356
|
+
</Project>
|
2357
|
+
""",
|
2358
|
+
packagesConfigContents: """
|
2359
|
+
<packages>
|
2360
|
+
<package id="Some.Package" version="1.0.0" targetFramework="net45" />
|
2361
|
+
</packages>
|
2362
|
+
""",
|
2363
|
+
additionalFiles:
|
2364
|
+
[
|
2365
|
+
("NuGet.Config", $"""
|
2366
|
+
<configuration>
|
2367
|
+
<packageSources>
|
2368
|
+
<clear />
|
2369
|
+
<add key="private_feed" value="{http.BaseUrl.TrimEnd('/')}/index.json" allowInsecureConnections="true" />
|
2370
|
+
</packageSources>
|
2371
|
+
</configuration>
|
2372
|
+
""")
|
2373
|
+
],
|
2374
|
+
// expected
|
2375
|
+
expectedProjectContents: """
|
2376
|
+
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
2377
|
+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
2378
|
+
<PropertyGroup>
|
2379
|
+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
2380
|
+
</PropertyGroup>
|
2381
|
+
<ItemGroup>
|
2382
|
+
<None Include="packages.config" />
|
2383
|
+
</ItemGroup>
|
2384
|
+
<ItemGroup>
|
2385
|
+
<Reference Include="Some.Package, Version=1.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed">
|
2386
|
+
<HintPath>packages\Some.Package.1.0.0\lib\net45\Some.Package.dll</HintPath>
|
2387
|
+
<Private>True</Private>
|
2388
|
+
</Reference>
|
2389
|
+
</ItemGroup>
|
2390
|
+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
2391
|
+
</Project>
|
2392
|
+
""",
|
2393
|
+
expectedPackagesConfigContents: """
|
2394
|
+
<packages>
|
2395
|
+
<package id="Some.Package" version="1.0.0" targetFramework="net45" />
|
2396
|
+
</packages>
|
2397
|
+
""",
|
2398
|
+
expectedResult: new()
|
2399
|
+
{
|
2400
|
+
ErrorType = ErrorType.Unknown,
|
2401
|
+
ErrorDetailsRegex = "Response status code does not indicate success",
|
2402
|
+
}
|
2403
|
+
);
|
2404
|
+
}
|
2405
|
+
|
2193
2406
|
[Fact]
|
2194
2407
|
public async Task MissingDependencyErrorIsReported()
|
2195
2408
|
{
|
@@ -2279,7 +2492,7 @@ public partial class UpdateWorkerTests
|
|
2279
2492
|
(string Path, string Content)[]? additionalFiles = null,
|
2280
2493
|
(string Path, string Content)[]? additionalFilesExpected = null,
|
2281
2494
|
MockNuGetPackage[]? packages = null,
|
2282
|
-
|
2495
|
+
ExpectedUpdateOperationResult? expectedResult = null)
|
2283
2496
|
{
|
2284
2497
|
var realizedAdditionalFiles = new List<(string Path, string Content)>
|
2285
2498
|
{
|