dependabot-nuget 0.284.0 → 0.286.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/helpers/lib/NuGetUpdater/NuGetProjects/Directory.Build.props +5 -1
  3. data/helpers/lib/NuGetUpdater/NuGetProjects/NuGet.CommandLine/NuGet.CommandLine.csproj +1 -0
  4. data/helpers/lib/NuGetUpdater/NuGetProjects/NuGet.Configuration/NuGet.Configuration.csproj +1 -0
  5. data/helpers/lib/NuGetUpdater/NuGetProjects/NuGet.LibraryModel/NuGet.LibraryModel.csproj +1 -0
  6. data/helpers/lib/NuGetUpdater/NuGetProjects/NuGet.Packaging/NuGet.Packaging.csproj +1 -1
  7. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/RunCommand.cs +8 -1
  8. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/UpdateCommand.cs +7 -3
  9. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Update.cs +11 -0
  10. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/AnalyzeWorker.cs +1 -1
  11. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DiscoveryWorker.cs +2 -2
  12. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/ExperimentsManager.cs +52 -0
  13. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/IAnalyzeWorker.cs +9 -0
  14. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/IDiscoveryWorker.cs +8 -0
  15. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/IUpdaterWorker.cs +9 -0
  16. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/RunWorker.cs +104 -33
  17. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/PackageReferenceUpdater.cs +6 -5
  18. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/PackagesConfigUpdater.cs +37 -5
  19. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/UpdaterWorker.cs +5 -3
  20. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/MSBuildHelper.cs +0 -5
  21. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/PathHelper.cs +2 -0
  22. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/RunWorkerTests.cs +975 -57
  23. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/SerializationTests.cs +168 -0
  24. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/UpdatedDependencyListTests.cs +53 -6
  25. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/TestAnalyzeWorker.cs +37 -0
  26. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/TestDiscoveryWorker.cs +35 -0
  27. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/TestUpdaterWorker.cs +39 -0
  28. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/PackagesConfigUpdaterTests.cs +104 -3
  29. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTestBase.cs +51 -13
  30. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.DirsProj.cs +4 -2
  31. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackageReference.cs +22 -17
  32. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackagesConfig.cs +1 -1
  33. data/lib/dependabot/nuget/file_updater.rb +8 -3
  34. data/lib/dependabot/nuget/native_helpers.rb +11 -12
  35. metadata +12 -6
  36. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/DependencySolverEnvironment.cs +0 -12
@@ -1,3 +1,7 @@
1
+ using System.Text.Json;
2
+
3
+ using NuGetUpdater.Core.Run;
4
+ using NuGetUpdater.Core.Run.ApiModel;
1
5
  using NuGetUpdater.Core.Test.Updater;
2
6
  using NuGetUpdater.Core.Updater;
3
7
 
@@ -19,11 +23,12 @@ public abstract class UpdateWorkerTestBase : TestBase
19
23
  bool isTransitive = false,
20
24
  TestFile[]? additionalFiles = null,
21
25
  MockNuGetPackage[]? packages = null,
26
+ ExperimentsManager? experimentsManager = null,
22
27
  string projectFilePath = "test-project.csproj")
23
28
  {
24
29
  return useSolution
25
- ? TestNoChangeforSolution(dependencyName, oldVersion, newVersion, projectFiles: [(projectFilePath, projectContents)], isTransitive, additionalFiles, packages)
26
- : TestNoChangeforProject(dependencyName, oldVersion, newVersion, projectContents, isTransitive, additionalFiles, packages, projectFilePath);
30
+ ? TestNoChangeforSolution(dependencyName, oldVersion, newVersion, projectFiles: [(projectFilePath, projectContents)], isTransitive, additionalFiles, packages, experimentsManager)
31
+ : TestNoChangeforProject(dependencyName, oldVersion, newVersion, projectContents, isTransitive, additionalFiles, packages, experimentsManager, projectFilePath);
27
32
  }
28
33
 
29
34
  protected static Task TestUpdate(
@@ -37,11 +42,12 @@ public abstract class UpdateWorkerTestBase : TestBase
37
42
  TestFile[]? additionalFiles = null,
38
43
  TestFile[]? additionalFilesExpected = null,
39
44
  MockNuGetPackage[]? packages = null,
45
+ ExperimentsManager? experimentsManager = null,
40
46
  string projectFilePath = "test-project.csproj")
41
47
  {
42
48
  return useSolution
43
- ? TestUpdateForSolution(dependencyName, oldVersion, newVersion, projectFiles: [(projectFilePath, projectContents)], projectFilesExpected: [(projectFilePath, expectedProjectContents)], isTransitive, additionalFiles, additionalFilesExpected, packages)
44
- : TestUpdateForProject(dependencyName, oldVersion, newVersion, projectFile: (projectFilePath, projectContents), expectedProjectContents, isTransitive, additionalFiles, additionalFilesExpected, packages);
49
+ ? TestUpdateForSolution(dependencyName, oldVersion, newVersion, projectFiles: [(projectFilePath, projectContents)], projectFilesExpected: [(projectFilePath, expectedProjectContents)], isTransitive, additionalFiles, additionalFilesExpected, packages, experimentsManager)
50
+ : TestUpdateForProject(dependencyName, oldVersion, newVersion, projectFile: (projectFilePath, projectContents), expectedProjectContents, isTransitive, additionalFiles, additionalFilesExpected, packages, experimentsManager);
45
51
  }
46
52
 
47
53
  protected static Task TestUpdate(
@@ -54,11 +60,12 @@ public abstract class UpdateWorkerTestBase : TestBase
54
60
  bool isTransitive = false,
55
61
  TestFile[]? additionalFiles = null,
56
62
  TestFile[]? additionalFilesExpected = null,
57
- MockNuGetPackage[]? packages = null)
63
+ MockNuGetPackage[]? packages = null,
64
+ ExperimentsManager? experimentsManager = null)
58
65
  {
59
66
  return useSolution
60
- ? TestUpdateForSolution(dependencyName, oldVersion, newVersion, projectFiles: [projectFile], projectFilesExpected: [(projectFile.Path, expectedProjectContents)], isTransitive, additionalFiles, additionalFilesExpected, packages)
61
- : TestUpdateForProject(dependencyName, oldVersion, newVersion, projectFile, expectedProjectContents, isTransitive, additionalFiles, additionalFilesExpected, packages);
67
+ ? TestUpdateForSolution(dependencyName, oldVersion, newVersion, projectFiles: [projectFile], projectFilesExpected: [(projectFile.Path, expectedProjectContents)], isTransitive, additionalFiles, additionalFilesExpected, packages, experimentsManager)
68
+ : TestUpdateForProject(dependencyName, oldVersion, newVersion, projectFile, expectedProjectContents, isTransitive, additionalFiles, additionalFilesExpected, packages, experimentsManager);
62
69
  }
63
70
 
64
71
  protected static Task TestNoChangeforProject(
@@ -69,6 +76,7 @@ public abstract class UpdateWorkerTestBase : TestBase
69
76
  bool isTransitive = false,
70
77
  TestFile[]? additionalFiles = null,
71
78
  MockNuGetPackage[]? packages = null,
79
+ ExperimentsManager? experimentsManager = null,
72
80
  string projectFilePath = "test-project.csproj")
73
81
  => TestUpdateForProject(
74
82
  dependencyName,
@@ -79,7 +87,8 @@ public abstract class UpdateWorkerTestBase : TestBase
79
87
  isTransitive,
80
88
  additionalFiles,
81
89
  additionalFilesExpected: additionalFiles,
82
- packages: packages);
90
+ packages: packages,
91
+ experimentsManager: experimentsManager);
83
92
 
84
93
  protected static Task TestUpdateForProject(
85
94
  string dependencyName,
@@ -91,6 +100,7 @@ public abstract class UpdateWorkerTestBase : TestBase
91
100
  TestFile[]? additionalFiles = null,
92
101
  TestFile[]? additionalFilesExpected = null,
93
102
  MockNuGetPackage[]? packages = null,
103
+ ExperimentsManager? experimentsManager = null,
94
104
  string projectFilePath = "test-project.csproj",
95
105
  ExpectedUpdateOperationResult? expectedResult = null)
96
106
  => TestUpdateForProject(
@@ -103,6 +113,7 @@ public abstract class UpdateWorkerTestBase : TestBase
103
113
  additionalFiles,
104
114
  additionalFilesExpected,
105
115
  packages,
116
+ experimentsManager,
106
117
  expectedResult);
107
118
 
108
119
  protected static async Task TestUpdateForProject(
@@ -115,6 +126,7 @@ public abstract class UpdateWorkerTestBase : TestBase
115
126
  TestFile[]? additionalFiles = null,
116
127
  TestFile[]? additionalFilesExpected = null,
117
128
  MockNuGetPackage[]? packages = null,
129
+ ExperimentsManager? experimentsManager = null,
118
130
  ExpectedUpdateOperationResult? expectedResult = null)
119
131
  {
120
132
  additionalFiles ??= [];
@@ -134,7 +146,8 @@ public abstract class UpdateWorkerTestBase : TestBase
134
146
  await MockNuGetPackagesInDirectory(packages, temporaryDirectory);
135
147
 
136
148
  // run update
137
- var worker = new UpdaterWorker(new TestLogger());
149
+ experimentsManager ??= new ExperimentsManager();
150
+ var worker = new UpdaterWorker(experimentsManager, new TestLogger());
138
151
  var projectPath = placeFilesInSrc ? $"src/{projectFilePath}" : projectFilePath;
139
152
  var actualResult = await worker.RunWithErrorHandlingAsync(temporaryDirectory, projectPath, dependencyName, oldVersion, newVersion, isTransitive);
140
153
  if (expectedResult is { })
@@ -172,7 +185,8 @@ public abstract class UpdateWorkerTestBase : TestBase
172
185
  TestFile[] projectFiles,
173
186
  bool isTransitive = false,
174
187
  TestFile[]? additionalFiles = null,
175
- MockNuGetPackage[]? packages = null)
188
+ MockNuGetPackage[]? packages = null,
189
+ ExperimentsManager? experimentsManager = null)
176
190
  => TestUpdateForSolution(
177
191
  dependencyName,
178
192
  oldVersion,
@@ -182,7 +196,8 @@ public abstract class UpdateWorkerTestBase : TestBase
182
196
  isTransitive,
183
197
  additionalFiles,
184
198
  additionalFilesExpected: additionalFiles,
185
- packages: packages);
199
+ packages: packages,
200
+ experimentsManager: experimentsManager);
186
201
 
187
202
  protected static async Task TestUpdateForSolution(
188
203
  string dependencyName,
@@ -193,7 +208,8 @@ public abstract class UpdateWorkerTestBase : TestBase
193
208
  bool isTransitive = false,
194
209
  TestFile[]? additionalFiles = null,
195
210
  TestFile[]? additionalFilesExpected = null,
196
- MockNuGetPackage[]? packages = null)
211
+ MockNuGetPackage[]? packages = null,
212
+ ExperimentsManager? experimentsManager = null)
197
213
  {
198
214
  additionalFiles ??= [];
199
215
  additionalFilesExpected ??= [];
@@ -236,8 +252,9 @@ public abstract class UpdateWorkerTestBase : TestBase
236
252
  {
237
253
  await MockNuGetPackagesInDirectory(packages, temporaryDirectory);
238
254
 
255
+ experimentsManager ??= new ExperimentsManager();
239
256
  var slnPath = Path.Combine(temporaryDirectory, slnName);
240
- var worker = new UpdaterWorker(new TestLogger());
257
+ var worker = new UpdaterWorker(experimentsManager, new TestLogger());
241
258
  await worker.RunAsync(temporaryDirectory, slnPath, dependencyName, oldVersion, newVersion, isTransitive);
242
259
  });
243
260
 
@@ -246,6 +263,27 @@ public abstract class UpdateWorkerTestBase : TestBase
246
263
  AssertContainsFiles(expectedResult, actualResult);
247
264
  }
248
265
 
266
+ public static async Task MockJobFileInDirectory(string temporaryDirectory)
267
+ {
268
+ var jobFile = new JobFile()
269
+ {
270
+ Job = new()
271
+ {
272
+ AllowedUpdates =
273
+ [
274
+ new() { UpdateType = "all" }
275
+ ],
276
+ Source = new()
277
+ {
278
+ Provider = "github",
279
+ Repo = "test/repo",
280
+ Directory = "/",
281
+ }
282
+ }
283
+ };
284
+ await File.WriteAllTextAsync(Path.Join(temporaryDirectory, "job.json"), JsonSerializer.Serialize(jobFile, RunWorker.SerializerOptions));
285
+ }
286
+
249
287
  public static async Task MockNuGetPackagesInDirectory(MockNuGetPackage[]? packages, string temporaryDirectory)
250
288
  {
251
289
  if (packages is not null)
@@ -350,7 +350,8 @@ public partial class UpdateWorkerTests
350
350
  bool isTransitive = false,
351
351
  (string Path, string Content)[]? additionalFiles = null,
352
352
  (string Path, string Content)[]? additionalFilesExpected = null,
353
- MockNuGetPackage[]? packages = null)
353
+ MockNuGetPackage[]? packages = null,
354
+ ExperimentsManager? experimentsManager = null)
354
355
  {
355
356
  additionalFiles ??= [];
356
357
  additionalFilesExpected ??= [];
@@ -363,8 +364,9 @@ public partial class UpdateWorkerTests
363
364
  {
364
365
  await MockNuGetPackagesInDirectory(packages, temporaryDirectory);
365
366
 
367
+ experimentsManager ??= new ExperimentsManager();
366
368
  var projectPath = Path.Combine(temporaryDirectory, projectFileName);
367
- var worker = new UpdaterWorker(new TestLogger());
369
+ var worker = new UpdaterWorker(experimentsManager, new TestLogger());
368
370
  await worker.RunAsync(temporaryDirectory, projectPath, dependencyName, oldVersion, newVersion, isTransitive);
369
371
  });
370
372
 
@@ -56,11 +56,12 @@ public partial class UpdateWorkerTests
56
56
  [Theory]
57
57
  [InlineData(true)]
58
58
  [InlineData(false)]
59
- public async Task UpdateVersionChildElement_InProjectFile_ForPackageReferenceIncludeTheory(bool useDependencySolver)
59
+ public async Task UpdateVersionChildElement_InProjectFile_ForPackageReferenceIncludeTheory(bool useLegacyDependencySolver)
60
60
  {
61
61
  // update Some.Package from 9.0.1 to 13.0.1
62
- using var _ = new DependencySolverEnvironment(useDependencySolver);
62
+ var experimentsManager = new ExperimentsManager() { UseLegacyDependencySolver = useLegacyDependencySolver };
63
63
  await TestUpdateForProject("Some.Package", "9.0.1", "13.0.1",
64
+ experimentsManager: experimentsManager,
64
65
  packages:
65
66
  [
66
67
  MockNuGetPackage.CreateSimplePackage("Some.Package", "9.0.1", "net8.0"),
@@ -98,10 +99,11 @@ public partial class UpdateWorkerTests
98
99
  [Theory]
99
100
  [InlineData(true)]
100
101
  [InlineData(false)]
101
- public async Task PeerDependenciesAreUpdatedEvenWhenNotExplicit(bool useDependencySolver)
102
+ public async Task PeerDependenciesAreUpdatedEvenWhenNotExplicit(bool useLegacyDependencySolver)
102
103
  {
103
- using var _ = new DependencySolverEnvironment(useDependencySolver);
104
+ var experimentsManager = new ExperimentsManager() { UseLegacyDependencySolver = useLegacyDependencySolver };
104
105
  await TestUpdateForProject("Some.Package", "1.0.0", "2.0.0",
106
+ experimentsManager: experimentsManager,
105
107
  packages:
106
108
  [
107
109
  MockNuGetPackage.CreateSimplePackage("Some.Package", "1.0.0", "net8.0", [(null, [("Transitive.Package", "[1.0.0]")])]),
@@ -160,7 +162,6 @@ public partial class UpdateWorkerTests
160
162
  public async Task CallingResolveDependencyConflictsNew()
161
163
  {
162
164
  // update Microsoft.CodeAnalysis.Common from 4.9.2 to 4.10.0
163
- using var _ = new DependencySolverEnvironment();
164
165
  await TestUpdateForProject("Microsoft.CodeAnalysis.Common", "4.9.2", "4.10.0",
165
166
  // initial
166
167
  projectContents: $"""
@@ -515,7 +516,7 @@ public partial class UpdateWorkerTests
515
516
  //
516
517
  // do the update
517
518
  //
518
- UpdaterWorker worker = new(new TestLogger());
519
+ UpdaterWorker worker = new(new ExperimentsManager(), new TestLogger());
519
520
  await worker.RunAsync(tempDirectory.DirectoryPath, projectPath, "Some.Package", "1.0.0", "1.1.0", isTransitive: false);
520
521
 
521
522
  //
@@ -598,11 +599,12 @@ public partial class UpdateWorkerTests
598
599
  [Theory]
599
600
  [InlineData(true)]
600
601
  [InlineData(false)]
601
- public async Task AddPackageReference_InProjectFile_ForTransientDependency(bool useDependencySolver)
602
+ public async Task AddPackageReference_InProjectFile_ForTransientDependency(bool useLegacyDependencySolver)
602
603
  {
603
- using var _ = new DependencySolverEnvironment(useDependencySolver);
604
+ var experimentsManager = new ExperimentsManager() { UseLegacyDependencySolver = useLegacyDependencySolver };
604
605
  // add transient package Some.Transient.Dependency from 5.0.1 to 5.0.2
605
606
  await TestUpdateForProject("Some.Transient.Dependency", "5.0.1", "5.0.2", isTransitive: true,
607
+ experimentsManager: experimentsManager,
606
608
  packages:
607
609
  [
608
610
  MockNuGetPackage.CreateSimplePackage("Some.Package", "3.1.3", "net8.0", [(null, [("Some.Transient.Dependency", "5.0.1")])]),
@@ -2979,7 +2981,6 @@ public partial class UpdateWorkerTests
2979
2981
  public async Task UpdatingTransitiveDependencyWithNewSolverCanUpdateJustTheTopLevelPackage()
2980
2982
  {
2981
2983
  // 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
2984
  await TestUpdateForProject("Transitive.Package", "1.0.0", "2.0.0",
2984
2985
  isTransitive: true,
2985
2986
  packages:
@@ -3017,13 +3018,14 @@ public partial class UpdateWorkerTests
3017
3018
  [Theory]
3018
3019
  [InlineData(true)]
3019
3020
  [InlineData(false)]
3020
- public async Task NoChange_IfThereAreIncoherentVersions(bool useDependencySolver)
3021
+ public async Task NoChange_IfThereAreIncoherentVersions(bool useLegacyDependencySolver)
3021
3022
  {
3022
- using var _ = new DependencySolverEnvironment(useDependencySolver);
3023
+ var experimentsManager = new ExperimentsManager() { UseLegacyDependencySolver = useLegacyDependencySolver };
3023
3024
 
3024
3025
  // trying to update `Transitive.Dependency` to 1.1.0 would normally pull `Some.Package` from 1.0.0 to 1.1.0,
3025
3026
  // but the TFM doesn't allow it
3026
3027
  await TestNoChangeforProject("Transitive.Dependency", "1.0.0", "1.1.0",
3028
+ experimentsManager: experimentsManager,
3027
3029
  packages:
3028
3030
  [
3029
3031
  MockNuGetPackage.CreateSimplePackage("Some.Package", "1.0.0", "net7.0", [(null, [("Transitive.Dependency", "[1.0.0]")])]),
@@ -3143,12 +3145,13 @@ public partial class UpdateWorkerTests
3143
3145
  [Theory]
3144
3146
  [InlineData(true)]
3145
3147
  [InlineData(false)]
3146
- public async Task UnresolvablePropertyDoesNotStopOtherUpdates(bool useDependencySolver)
3148
+ public async Task UnresolvablePropertyDoesNotStopOtherUpdates(bool useLegacyDependencySolver)
3147
3149
  {
3148
- using var _ = new DependencySolverEnvironment(useDependencySolver);
3150
+ var experimentsManager = new ExperimentsManager() { UseLegacyDependencySolver = useLegacyDependencySolver };
3149
3151
 
3150
3152
  // the property `$(SomeUnresolvableProperty)` cannot be resolved
3151
3153
  await TestUpdateForProject("Some.Package", "7.0.1", "13.0.1",
3154
+ experimentsManager: experimentsManager,
3152
3155
  packages:
3153
3156
  [
3154
3157
  MockNuGetPackage.CreateSimplePackage("Some.Package", "7.0.1", "net8.0"),
@@ -3184,12 +3187,13 @@ public partial class UpdateWorkerTests
3184
3187
  [Theory]
3185
3188
  [InlineData(true)]
3186
3189
  [InlineData(false)]
3187
- public async Task ProjectWithWorkloadsShouldNotFail(bool useDependencySolver)
3190
+ public async Task ProjectWithWorkloadsShouldNotFail(bool useLegacyDependencySolver)
3188
3191
  {
3189
- using var _ = new DependencySolverEnvironment(useDependencySolver);
3192
+ var experimentsManager = new ExperimentsManager() { UseLegacyDependencySolver = useLegacyDependencySolver };
3190
3193
 
3191
3194
  // the property `$(SomeUnresolvableProperty)` cannot be resolved
3192
3195
  await TestUpdateForProject("Some.Package", "7.0.1", "13.0.1",
3196
+ experimentsManager: experimentsManager,
3193
3197
  packages:
3194
3198
  [
3195
3199
  MockNuGetPackage.CreateSimplePackage("Some.Package", "7.0.1", "net8.0"),
@@ -3224,12 +3228,13 @@ public partial class UpdateWorkerTests
3224
3228
  [Theory]
3225
3229
  [InlineData(true)]
3226
3230
  [InlineData(false)]
3227
- public async Task UpdatingPackageAlsoUpdatesAnythingWithADependencyOnTheUpdatedPackage(bool useDependencySolver)
3231
+ public async Task UpdatingPackageAlsoUpdatesAnythingWithADependencyOnTheUpdatedPackage(bool useLegacyDependencySolver)
3228
3232
  {
3229
- using var _ = new DependencySolverEnvironment(useDependencySolver);
3233
+ var experimentsManager = new ExperimentsManager() { UseLegacyDependencySolver = useLegacyDependencySolver };
3230
3234
 
3231
3235
  // updating Some.Package from 3.3.30 requires that Some.Package.Extensions also be updated
3232
3236
  await TestUpdateForProject("Some.Package", "3.3.30", "3.4.3",
3237
+ experimentsManager: experimentsManager,
3233
3238
  packages:
3234
3239
  [
3235
3240
  MockNuGetPackage.CreateSimplePackage("Some.Package", "3.3.30", "net8.0"),
@@ -2288,7 +2288,7 @@ public partial class UpdateWorkerTests
2288
2288
  await MockNuGetPackagesInDirectory(packages, Path.Combine(temporaryDirectory.DirectoryPath, "packages"));
2289
2289
  var resultOutputPath = Path.Combine(temporaryDirectory.DirectoryPath, "result.json");
2290
2290
 
2291
- var worker = new UpdaterWorker(new TestLogger());
2291
+ var worker = new UpdaterWorker(new ExperimentsManager(), new TestLogger());
2292
2292
  await worker.RunAsync(temporaryDirectory.DirectoryPath, "project.csproj", "Some.Package", "1.0.0", "1.1.0", isTransitive: false, resultOutputPath: resultOutputPath);
2293
2293
 
2294
2294
  var resultContents = await File.ReadAllTextAsync(resultOutputPath);
@@ -79,6 +79,11 @@ module Dependabot
79
79
 
80
80
  private
81
81
 
82
+ sig { returns(String) }
83
+ def job_file_path
84
+ ENV.fetch("DEPENDABOT_JOB_PATH")
85
+ end
86
+
82
87
  sig { params(dependency: Dependabot::Dependency).returns(T::Boolean) }
83
88
  def try_update_projects(dependency)
84
89
  update_ran = T.let(false, T::Boolean)
@@ -127,9 +132,9 @@ module Dependabot
127
132
 
128
133
  sig { params(dependency: Dependency, proj_path: String).void }
129
134
  def call_nuget_updater_tool(dependency, proj_path)
130
- NativeHelpers.run_nuget_updater_tool(repo_root: T.must(repo_contents_path), proj_path: proj_path,
131
- dependency: dependency, is_transitive: !dependency.top_level?,
132
- credentials: credentials)
135
+ NativeHelpers.run_nuget_updater_tool(job_path: job_file_path, repo_root: T.must(repo_contents_path),
136
+ proj_path: proj_path, dependency: dependency,
137
+ is_transitive: !dependency.top_level?, credentials: credentials)
133
138
 
134
139
  # Tests need to track how many times we call the tooling updater to ensure we don't recurse needlessly
135
140
  # Ideally we should find a way to not run this code in prod
@@ -165,14 +165,17 @@ module Dependabot
165
165
 
166
166
  # rubocop:disable Metrics/MethodLength
167
167
  sig do
168
- params(repo_root: String, proj_path: String, dependency: Dependency,
168
+ params(job_path: String, repo_root: String, proj_path: String, dependency: Dependency,
169
169
  is_transitive: T::Boolean, result_output_path: String).returns([String, String])
170
170
  end
171
- def self.get_nuget_updater_tool_command(repo_root:, proj_path:, dependency:, is_transitive:, result_output_path:)
171
+ def self.get_nuget_updater_tool_command(job_path:, repo_root:, proj_path:, dependency:, is_transitive:,
172
+ result_output_path:)
172
173
  exe_path = File.join(native_helpers_root, "NuGetUpdater", "NuGetUpdater.Cli")
173
174
  command_parts = [
174
175
  exe_path,
175
176
  "update",
177
+ "--job-path",
178
+ job_path,
176
179
  "--repo-root",
177
180
  repo_root,
178
181
  "--solution-or-project",
@@ -219,6 +222,7 @@ module Dependabot
219
222
 
220
223
  sig do
221
224
  params(
225
+ job_path: String,
222
226
  repo_root: String,
223
227
  proj_path: String,
224
228
  dependency: Dependency,
@@ -226,23 +230,18 @@ module Dependabot
226
230
  credentials: T::Array[Dependabot::Credential]
227
231
  ).void
228
232
  end
229
- def self.run_nuget_updater_tool(repo_root:, proj_path:, dependency:, is_transitive:, credentials:)
230
- (command, fingerprint) = get_nuget_updater_tool_command(repo_root: repo_root, proj_path: proj_path,
231
- dependency: dependency, is_transitive: is_transitive,
233
+ def self.run_nuget_updater_tool(job_path:, repo_root:, proj_path:, dependency:, is_transitive:, credentials:)
234
+ (command, fingerprint) = get_nuget_updater_tool_command(job_path: job_path, repo_root: repo_root,
235
+ proj_path: proj_path, dependency: dependency,
236
+ is_transitive: is_transitive,
232
237
  result_output_path: update_result_file_path)
233
238
 
234
239
  puts "running NuGet updater:\n" + command
235
240
 
236
241
  NuGetConfigCredentialHelpers.patch_nuget_config_for_action(credentials) do
237
- # default to UseNewNugetPackageResolved _unless_ nuget_legacy_dependency_solver is enabled
238
- env = {}
239
- unless Dependabot::Experiments.enabled?(:nuget_legacy_dependency_solver)
240
- env["UseNewNugetPackageResolver"] = "true"
241
- end
242
242
  output = SharedHelpers.run_shell_command(command,
243
243
  allow_unsafe_shell_command: true,
244
- fingerprint: fingerprint,
245
- env: env)
244
+ fingerprint: fingerprint)
246
245
  puts output
247
246
 
248
247
  result_contents = File.read(update_result_file_path)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dependabot-nuget
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.284.0
4
+ version: 0.286.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dependabot
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-11-05 00:00:00.000000000 Z
11
+ date: 2024-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dependabot-common
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.284.0
19
+ version: 0.286.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 0.284.0
26
+ version: 0.286.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rubyzip
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -313,7 +313,6 @@ files:
313
313
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Analyze/VersionFinderTests.cs
314
314
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Clone/CloneWorkerTests.cs
315
315
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Clone/TestGitCommandHandler.cs
316
- - helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/DependencySolverEnvironment.cs
317
316
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTestBase.cs
318
317
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.DotNetToolsJson.cs
319
318
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.GlobalJson.cs
@@ -337,10 +336,13 @@ files:
337
336
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/UpdatedDependencyListTests.cs
338
337
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/TemporaryDirectory.cs
339
338
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/TemporaryEnvironment.cs
339
+ - helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/TestAnalyzeWorker.cs
340
340
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/TestBase.cs
341
+ - helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/TestDiscoveryWorker.cs
341
342
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/TestExtensions.cs
342
343
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/TestHttpServer.cs
343
344
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/TestLogger.cs
345
+ - helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/TestUpdaterWorker.cs
344
346
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/BindingRedirectsTests.cs
345
347
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/ExpectedUpdateOperationResult.cs
346
348
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/PackagesConfigUpdaterTests.cs
@@ -391,6 +393,7 @@ files:
391
393
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core/ErrorType.cs
392
394
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core/EvaluationResult.cs
393
395
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core/EvaluationResultType.cs
396
+ - helpers/lib/NuGetUpdater/NuGetUpdater.Core/ExperimentsManager.cs
394
397
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/BuildFile.cs
395
398
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/DotNetToolsJsonBuildFile.cs
396
399
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/GlobalJsonBuildFile.cs
@@ -401,6 +404,9 @@ files:
401
404
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core/FrameworkChecker/CompatabilityChecker.cs
402
405
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core/FrameworkChecker/FrameworkCompatibilityService.cs
403
406
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core/FrameworkChecker/SupportedFrameworks.cs
407
+ - helpers/lib/NuGetUpdater/NuGetUpdater.Core/IAnalyzeWorker.cs
408
+ - helpers/lib/NuGetUpdater/NuGetUpdater.Core/IDiscoveryWorker.cs
409
+ - helpers/lib/NuGetUpdater/NuGetUpdater.Core/IUpdaterWorker.cs
404
410
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core/MissingFileException.cs
405
411
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core/NativeResult.cs
406
412
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core/NuGetUpdater.Core.csproj
@@ -505,7 +511,7 @@ licenses:
505
511
  - MIT
506
512
  metadata:
507
513
  bug_tracker_uri: https://github.com/dependabot/dependabot-core/issues
508
- changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.284.0
514
+ changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.286.0
509
515
  post_install_message:
510
516
  rdoc_options: []
511
517
  require_paths:
@@ -1,12 +0,0 @@
1
- namespace NuGetUpdater.Core.Test;
2
-
3
- /// <summary>
4
- /// Prepares the environment to use the new dependency solver.
5
- /// </summary>
6
- public class DependencySolverEnvironment : TemporaryEnvironment
7
- {
8
- public DependencySolverEnvironment(bool useDependencySolver = true)
9
- : base([("UseNewNugetPackageResolver", useDependencySolver ? "true" : "false")])
10
- {
11
- }
12
- }