dependabot-nuget 0.288.0 → 0.290.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/helpers/lib/NuGetUpdater/Directory.Packages.props +19 -17
- data/helpers/lib/NuGetUpdater/NuGetProjects/NuGet.Packaging/NuGet.Packaging.csproj +0 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/AnalyzeCommand.cs +7 -3
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/RunCommand.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Analyze.cs +29 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Discover.cs +25 -4
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Run.cs +0 -6
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/AnalyzeWorker.cs +33 -16
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/CompatabilityChecker.cs +25 -10
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/NuGetContext.cs +0 -13
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/RequirementArrayConverter.cs +39 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/VersionFinder.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Clone/ShellGitCommandHandler.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DiscoveryWorker.cs +60 -66
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DotNetToolsJsonDiscovery.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/GlobalJsonDiscovery.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/PackagesConfigDiscovery.cs +11 -3
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/PackagesConfigDiscoveryResult.cs +1 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/ProjectDiscoveryResult.cs +2 -4
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/SdkProjectDiscovery.cs +54 -11
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/WorkspaceDiscoveryResult.cs +0 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/ExperimentsManager.cs +1 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/JsonBuildFile.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/FrameworkChecker/CompatabilityChecker.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/Advisory.cs +13 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/AllowedUpdate.cs +18 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/CommitOptions.cs +8 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/Condition.cs +19 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/DependencyGroup.cs +8 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/GroupPullRequest.cs +9 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/Job.cs +13 -10
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/PullRequest.cs +11 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/RequirementsUpdateStrategy.cs +15 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/RunWorker.cs +67 -58
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/VersionConverter.cs +19 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/BindingRedirectManager.cs +15 -44
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/DotNetToolsJsonUpdater.cs +4 -4
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/GlobalJsonUpdater.cs +5 -5
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/LockFileUpdater.cs +2 -10
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/PackageReferenceUpdater.cs +38 -33
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/PackagesConfigUpdater.cs +25 -23
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/UpdaterWorker.cs +16 -12
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/ConsoleLogger.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/DependencyConflictResolver.cs +19 -19
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/ILogger.cs +11 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/JsonHelper.cs +2 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/MSBuildHelper.cs +18 -17
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/NuGetHelper.cs +1 -17
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/PathHelper.cs +17 -9
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/ProjectHelper.cs +96 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Analyze/AnalyzeWorkerTestBase.cs +5 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Analyze/AnalyzeWorkerTests.cs +87 -5
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTestBase.cs +2 -5
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.DotNetToolsJson.cs +45 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.GlobalJson.cs +35 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.PackagesConfig.cs +16 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.Proj.cs +6 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.Project.cs +143 -36
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.cs +184 -48
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/ExpectedDiscoveryResults.cs +5 -5
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/SdkProjectDiscoveryTests.cs +32 -10
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/MiscellaneousTests.cs +85 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/RunWorkerTests.cs +402 -102
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/SerializationTests.cs +342 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/UpdatedDependencyListTests.cs +60 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/TemporaryDirectory.cs +18 -7
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/TestLogger.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/BindingRedirectsTests.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/PackagesConfigUpdaterTests.cs +24 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTestBase.cs +4 -14
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.DotNetTools.cs +84 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.GlobalJson.cs +66 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackageReference.cs +95 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackagesConfig.cs +1 -7
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/AssertEx.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/LinuxOnlyAttribute.cs +12 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/MSBuildHelperTests.cs +558 -711
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/PathHelperTests.cs +47 -2
- data/lib/dependabot/nuget/analysis/analysis_json_reader.rb +4 -2
- data/lib/dependabot/nuget/analysis/dependency_analysis.rb +3 -3
- data/lib/dependabot/nuget/discovery/dependency_details.rb +10 -3
- data/lib/dependabot/nuget/discovery/dependency_file_discovery.rb +8 -12
- data/lib/dependabot/nuget/discovery/discovery_json_reader.rb +214 -29
- data/lib/dependabot/nuget/discovery/project_discovery.rb +41 -8
- data/lib/dependabot/nuget/discovery/workspace_discovery.rb +14 -19
- data/lib/dependabot/nuget/file_fetcher.rb +11 -393
- data/lib/dependabot/nuget/file_parser.rb +23 -61
- data/lib/dependabot/nuget/file_updater.rb +28 -23
- data/lib/dependabot/nuget/native_helpers.rb +14 -5
- data/lib/dependabot/nuget/update_checker/requirements_updater.rb +23 -27
- data/lib/dependabot/nuget/update_checker.rb +116 -190
- metadata +20 -32
- data/helpers/lib/NuGetUpdater/NuGetProjects/Directory.Packages.props +0 -29
- data/lib/dependabot/nuget/discovery/directory_packages_props_discovery.rb +0 -43
- data/lib/dependabot/nuget/file_fetcher/import_paths_finder.rb +0 -73
- data/lib/dependabot/nuget/file_fetcher/sln_project_paths_finder.rb +0 -60
- data/lib/dependabot/nuget/http_response_helpers.rb +0 -19
- data/lib/dependabot/nuget/native_discovery/native_dependency_details.rb +0 -102
- data/lib/dependabot/nuget/native_discovery/native_dependency_file_discovery.rb +0 -129
- data/lib/dependabot/nuget/native_discovery/native_discovery_json_reader.rb +0 -171
- data/lib/dependabot/nuget/native_discovery/native_evaluation_details.rb +0 -63
- data/lib/dependabot/nuget/native_discovery/native_project_discovery.rb +0 -82
- data/lib/dependabot/nuget/native_discovery/native_property_details.rb +0 -43
- data/lib/dependabot/nuget/native_discovery/native_workspace_discovery.rb +0 -68
- data/lib/dependabot/nuget/native_update_checker/native_requirements_updater.rb +0 -105
- data/lib/dependabot/nuget/native_update_checker/native_update_checker.rb +0 -201
- data/lib/dependabot/nuget/nuget_client.rb +0 -223
- data/lib/dependabot/nuget/update_checker/compatibility_checker.rb +0 -116
- data/lib/dependabot/nuget/update_checker/dependency_finder.rb +0 -297
- data/lib/dependabot/nuget/update_checker/nupkg_fetcher.rb +0 -221
- data/lib/dependabot/nuget/update_checker/nuspec_fetcher.rb +0 -110
- data/lib/dependabot/nuget/update_checker/property_updater.rb +0 -196
- data/lib/dependabot/nuget/update_checker/repository_finder.rb +0 -466
- data/lib/dependabot/nuget/update_checker/tfm_comparer.rb +0 -34
- data/lib/dependabot/nuget/update_checker/tfm_finder.rb +0 -30
- data/lib/dependabot/nuget/update_checker/version_finder.rb +0 -449
@@ -30,7 +30,7 @@ internal static class PackageReferenceUpdater
|
|
30
30
|
ILogger logger)
|
31
31
|
{
|
32
32
|
// PackageReference project; modify the XML directly
|
33
|
-
logger.
|
33
|
+
logger.Info(" Running 'PackageReference' project direct XML update");
|
34
34
|
|
35
35
|
(ImmutableArray<ProjectBuildFile> buildFiles, string[] tfms) = await MSBuildHelper.LoadBuildFilesAndTargetFrameworksAsync(repoRootPath, projectPath);
|
36
36
|
|
@@ -61,6 +61,11 @@ internal static class PackageReferenceUpdater
|
|
61
61
|
}
|
62
62
|
else
|
63
63
|
{
|
64
|
+
if (peerDependencies is null)
|
65
|
+
{
|
66
|
+
return;
|
67
|
+
}
|
68
|
+
|
64
69
|
await UpdateDependencyWithConflictResolution(repoRootPath, buildFiles, tfms, projectPath, dependencyName, previousDependencyVersion, newDependencyVersion, isTransitive, peerDependencies, logger);
|
65
70
|
}
|
66
71
|
|
@@ -105,7 +110,7 @@ internal static class PackageReferenceUpdater
|
|
105
110
|
var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(repoRootPath, projectFile.Path, tfm, topLevelDependencies, dependenciesToUpdate, logger);
|
106
111
|
if (resolvedDependencies is null)
|
107
112
|
{
|
108
|
-
logger.
|
113
|
+
logger.Warn($" Unable to resolve dependency conflicts for {projectFile.Path}.");
|
109
114
|
continue;
|
110
115
|
}
|
111
116
|
|
@@ -184,14 +189,14 @@ internal static class PackageReferenceUpdater
|
|
184
189
|
// Skip updating the project if the dependency does not exist in the graph
|
185
190
|
if (!packageFound)
|
186
191
|
{
|
187
|
-
logger.
|
192
|
+
logger.Info($" Package [{dependencyName}] Does not exist as a dependency in [{projectPath}].");
|
188
193
|
return false;
|
189
194
|
}
|
190
195
|
|
191
196
|
// Skip updating the project if the dependency version meets or exceeds the newDependencyVersion
|
192
197
|
if (!needsUpdate)
|
193
198
|
{
|
194
|
-
logger.
|
199
|
+
logger.Info($" Package [{dependencyName}] already meets the requested dependency version in [{projectPath}].");
|
195
200
|
return false;
|
196
201
|
}
|
197
202
|
|
@@ -242,7 +247,7 @@ internal static class PackageReferenceUpdater
|
|
242
247
|
a.Value.Equals(dependencyName, StringComparison.OrdinalIgnoreCase)))
|
243
248
|
.FirstOrDefault();
|
244
249
|
|
245
|
-
logger.
|
250
|
+
logger.Info($" Pinning [{dependencyName}/{newDependencyVersion}] as a package version.");
|
246
251
|
|
247
252
|
var lastPackageVersion = directoryPackages.ItemNodes
|
248
253
|
.Where(e => e.Name.Equals("PackageVersion", StringComparison.OrdinalIgnoreCase))
|
@@ -250,7 +255,7 @@ internal static class PackageReferenceUpdater
|
|
250
255
|
|
251
256
|
if (lastPackageVersion is null)
|
252
257
|
{
|
253
|
-
logger.
|
258
|
+
logger.Info($" Transitive dependency [{dependencyName}/{newDependencyVersion}] was not pinned.");
|
254
259
|
return;
|
255
260
|
}
|
256
261
|
|
@@ -260,7 +265,7 @@ internal static class PackageReferenceUpdater
|
|
260
265
|
if (existingPackageVersionElement is null)
|
261
266
|
{
|
262
267
|
// need to add a new entry
|
263
|
-
logger.
|
268
|
+
logger.Info(" New PackageVersion element added.");
|
264
269
|
var leadingTrivia = lastPackageVersion.AsNode.GetLeadingTrivia();
|
265
270
|
var packageVersionElement = XmlExtensions.CreateSingleLineXmlElementSyntax("PackageVersion", new SyntaxList<SyntaxNode>(leadingTrivia))
|
266
271
|
.WithAttribute("Include", dependencyName)
|
@@ -274,19 +279,19 @@ internal static class PackageReferenceUpdater
|
|
274
279
|
if (versionAttribute is null)
|
275
280
|
{
|
276
281
|
// need to add the version
|
277
|
-
logger.
|
282
|
+
logger.Info(" Adding version attribute to element.");
|
278
283
|
updatedPackageVersionElement = existingPackageVersionElement.WithAttribute("Version", newDependencyVersion);
|
279
284
|
}
|
280
285
|
else if (!versionAttribute.Value.Equals(newDependencyVersion, StringComparison.OrdinalIgnoreCase))
|
281
286
|
{
|
282
287
|
// need to update the version
|
283
|
-
logger.
|
288
|
+
logger.Info($" Updating version attribute of [{versionAttribute.Value}].");
|
284
289
|
var updatedVersionAttribute = versionAttribute.WithValue(newDependencyVersion);
|
285
290
|
updatedPackageVersionElement = existingPackageVersionElement.ReplaceAttribute(versionAttribute, updatedVersionAttribute);
|
286
291
|
}
|
287
292
|
else
|
288
293
|
{
|
289
|
-
logger.
|
294
|
+
logger.Info(" Existing PackageVersion element version was already correct.");
|
290
295
|
return;
|
291
296
|
}
|
292
297
|
|
@@ -302,14 +307,14 @@ internal static class PackageReferenceUpdater
|
|
302
307
|
var projectDirectory = Path.GetDirectoryName(projectPath)!;
|
303
308
|
await MSBuildHelper.SidelineGlobalJsonAsync(projectDirectory, repoRootPath, async () =>
|
304
309
|
{
|
305
|
-
logger.
|
310
|
+
logger.Info($" Adding [{dependencyName}/{newDependencyVersion}] as a top-level package reference.");
|
306
311
|
|
307
312
|
// see https://learn.microsoft.com/nuget/consume-packages/install-use-packages-dotnet-cli
|
308
313
|
var (exitCode, stdout, stderr) = await ProcessEx.RunAsync("dotnet", ["add", projectPath, "package", dependencyName, "--version", newDependencyVersion], workingDirectory: projectDirectory);
|
309
314
|
MSBuildHelper.ThrowOnUnauthenticatedFeed(stdout);
|
310
315
|
if (exitCode != 0)
|
311
316
|
{
|
312
|
-
logger.
|
317
|
+
logger.Warn($" Transitive dependency [{dependencyName}/{newDependencyVersion}] was not added.\nSTDOUT:\n{stdout}\nSTDERR:\n{stderr}");
|
313
318
|
}
|
314
319
|
|
315
320
|
return exitCode;
|
@@ -339,7 +344,7 @@ internal static class PackageReferenceUpdater
|
|
339
344
|
var unupgradableTfms = tfmsAndDependencies.Where(kvp => !kvp.Value.Any()).Select(kvp => kvp.Key);
|
340
345
|
if (unupgradableTfms.Any())
|
341
346
|
{
|
342
|
-
logger.
|
347
|
+
logger.Info($" The following target frameworks could not find packages to upgrade: {string.Join(", ", unupgradableTfms)}");
|
343
348
|
return null;
|
344
349
|
}
|
345
350
|
|
@@ -354,7 +359,7 @@ internal static class PackageReferenceUpdater
|
|
354
359
|
if (packagesAndVersions.TryGetValue(packageName, out var existingVersion) &&
|
355
360
|
existingVersion != packageVersion)
|
356
361
|
{
|
357
|
-
logger.
|
362
|
+
logger.Info($" Package [{packageName}] tried to update to version [{packageVersion}], but found conflicting package version of [{existingVersion}].");
|
358
363
|
conflictingPackageVersionsFound = true;
|
359
364
|
}
|
360
365
|
else
|
@@ -387,7 +392,7 @@ internal static class PackageReferenceUpdater
|
|
387
392
|
var result = TryUpdateDependencyVersion(buildFiles, dependencyName, previousDependencyVersion, newDependencyVersion, logger);
|
388
393
|
if (result == UpdateResult.NotFound)
|
389
394
|
{
|
390
|
-
logger.
|
395
|
+
logger.Info($" Root package [{dependencyName}/{previousDependencyVersion}] was not updated; skipping dependencies.");
|
391
396
|
return;
|
392
397
|
}
|
393
398
|
|
@@ -405,7 +410,7 @@ internal static class PackageReferenceUpdater
|
|
405
410
|
var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflictsWithBruteForce(repoRootPath, projectFile.Path, tfm, updatedTopLevelDependencies, logger);
|
406
411
|
if (resolvedDependencies is null)
|
407
412
|
{
|
408
|
-
logger.
|
413
|
+
logger.Info($" Unable to resolve dependency conflicts for {projectFile.Path}.");
|
409
414
|
continue;
|
410
415
|
}
|
411
416
|
|
@@ -413,13 +418,13 @@ internal static class PackageReferenceUpdater
|
|
413
418
|
var specificResolvedDependency = resolvedDependencies.Where(d => d.Name.Equals(dependencyName, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
|
414
419
|
if (specificResolvedDependency is null)
|
415
420
|
{
|
416
|
-
logger.
|
421
|
+
logger.Info($" Unable to resolve requested dependency for {dependencyName} in {projectFile.Path}.");
|
417
422
|
continue;
|
418
423
|
}
|
419
424
|
|
420
425
|
if (!newDependencyVersion.Equals(specificResolvedDependency.Version, StringComparison.OrdinalIgnoreCase))
|
421
426
|
{
|
422
|
-
logger.
|
427
|
+
logger.Info($" Inconsistent resolution for {dependencyName}; attempted upgrade to {newDependencyVersion} but resolved {specificResolvedDependency.Version}.");
|
423
428
|
continue;
|
424
429
|
}
|
425
430
|
|
@@ -476,12 +481,12 @@ internal static class PackageReferenceUpdater
|
|
476
481
|
var currentVersion = versionAttribute.Value.TrimStart('[', '(').TrimEnd(']', ')');
|
477
482
|
if (currentVersion.Contains(',') || currentVersion.Contains('*'))
|
478
483
|
{
|
479
|
-
logger.
|
484
|
+
logger.Warn($" Found unsupported [{packageNode.Name}] version attribute value [{versionAttribute.Value}] in [{buildFile.RelativePath}].");
|
480
485
|
foundUnsupported = true;
|
481
486
|
}
|
482
487
|
else if (string.Equals(currentVersion, previousDependencyVersion, StringComparison.Ordinal))
|
483
488
|
{
|
484
|
-
logger.
|
489
|
+
logger.Info($" Found incorrect [{packageNode.Name}] version attribute in [{buildFile.RelativePath}].");
|
485
490
|
updateNodes.Add(versionAttribute);
|
486
491
|
}
|
487
492
|
else if (previousDependencyVersion == null && NuGetVersion.TryParse(currentVersion, out var previousVersion))
|
@@ -491,13 +496,13 @@ internal static class PackageReferenceUpdater
|
|
491
496
|
{
|
492
497
|
previousPackageVersion = currentVersion;
|
493
498
|
|
494
|
-
logger.
|
499
|
+
logger.Info($" Found incorrect peer [{packageNode.Name}] version attribute in [{buildFile.RelativePath}].");
|
495
500
|
updateNodes.Add(versionAttribute);
|
496
501
|
}
|
497
502
|
}
|
498
503
|
else if (string.Equals(currentVersion, newDependencyVersion, StringComparison.Ordinal))
|
499
504
|
{
|
500
|
-
logger.
|
505
|
+
logger.Info($" Found correct [{packageNode.Name}] version attribute in [{buildFile.RelativePath}].");
|
501
506
|
foundCorrect = true;
|
502
507
|
}
|
503
508
|
}
|
@@ -514,12 +519,12 @@ internal static class PackageReferenceUpdater
|
|
514
519
|
var currentVersion = versionValue.TrimStart('[', '(').TrimEnd(']', ')');
|
515
520
|
if (currentVersion.Contains(',') || currentVersion.Contains('*'))
|
516
521
|
{
|
517
|
-
logger.
|
522
|
+
logger.Info($" Found unsupported [{packageNode.Name}] version node value [{versionValue}] in [{buildFile.RelativePath}].");
|
518
523
|
foundUnsupported = true;
|
519
524
|
}
|
520
525
|
else if (currentVersion == previousDependencyVersion)
|
521
526
|
{
|
522
|
-
logger.
|
527
|
+
logger.Info($" Found incorrect [{packageNode.Name}] version node in [{buildFile.RelativePath}].");
|
523
528
|
if (versionElement is XmlElementSyntax elementSyntax)
|
524
529
|
{
|
525
530
|
updateNodes.Add(elementSyntax);
|
@@ -536,7 +541,7 @@ internal static class PackageReferenceUpdater
|
|
536
541
|
{
|
537
542
|
previousPackageVersion = currentVersion;
|
538
543
|
|
539
|
-
logger.
|
544
|
+
logger.Info($" Found incorrect peer [{packageNode.Name}] version node in [{buildFile.RelativePath}].");
|
540
545
|
if (versionElement is XmlElementSyntax elementSyntax)
|
541
546
|
{
|
542
547
|
updateNodes.Add(elementSyntax);
|
@@ -550,7 +555,7 @@ internal static class PackageReferenceUpdater
|
|
550
555
|
}
|
551
556
|
else if (currentVersion == newDependencyVersion)
|
552
557
|
{
|
553
|
-
logger.
|
558
|
+
logger.Info($" Found correct [{packageNode.Name}] version node in [{buildFile.RelativePath}].");
|
554
559
|
foundCorrect = true;
|
555
560
|
}
|
556
561
|
}
|
@@ -558,7 +563,7 @@ internal static class PackageReferenceUpdater
|
|
558
563
|
else
|
559
564
|
{
|
560
565
|
// We weren't able to find the version node. Central package management?
|
561
|
-
logger.
|
566
|
+
logger.Warn(" Found package reference but was unable to locate version information.");
|
562
567
|
}
|
563
568
|
}
|
564
569
|
|
@@ -626,12 +631,12 @@ internal static class PackageReferenceUpdater
|
|
626
631
|
var currentVersion = propertyContents.TrimStart('[', '(').TrimEnd(']', ')');
|
627
632
|
if (currentVersion.Contains(',') || currentVersion.Contains('*'))
|
628
633
|
{
|
629
|
-
logger.
|
634
|
+
logger.Warn($" Found unsupported version property [{propertyElement.Name}] value [{propertyContents}] in [{buildFile.RelativePath}].");
|
630
635
|
foundUnsupported = true;
|
631
636
|
}
|
632
637
|
else if (currentVersion == previousDependencyVersion)
|
633
638
|
{
|
634
|
-
logger.
|
639
|
+
logger.Info($" Found incorrect version property [{propertyElement.Name}] in [{buildFile.RelativePath}].");
|
635
640
|
updateProperties.Add((XmlElementSyntax)propertyElement.AsNode);
|
636
641
|
}
|
637
642
|
else if (previousDependencyVersion is null && NuGetVersion.TryParse(currentVersion, out var previousVersion))
|
@@ -641,13 +646,13 @@ internal static class PackageReferenceUpdater
|
|
641
646
|
{
|
642
647
|
previousPackageVersion = currentVersion;
|
643
648
|
|
644
|
-
logger.
|
649
|
+
logger.Info($" Found incorrect peer version property [{propertyElement.Name}] in [{buildFile.RelativePath}].");
|
645
650
|
updateProperties.Add((XmlElementSyntax)propertyElement.AsNode);
|
646
651
|
}
|
647
652
|
}
|
648
653
|
else if (currentVersion == newDependencyVersion)
|
649
654
|
{
|
650
|
-
logger.
|
655
|
+
logger.Info($" Found correct version property [{propertyElement.Name}] in [{buildFile.RelativePath}].");
|
651
656
|
foundCorrect = true;
|
652
657
|
}
|
653
658
|
}
|
@@ -701,7 +706,7 @@ internal static class PackageReferenceUpdater
|
|
701
706
|
var dependenciesAreCoherent = await MSBuildHelper.DependenciesAreCoherentAsync(repoRootPath, projectPath, tfm, updatedPackages, logger);
|
702
707
|
if (!dependenciesAreCoherent)
|
703
708
|
{
|
704
|
-
logger.
|
709
|
+
logger.Warn($" Package [{dependencyName}] could not be updated in [{projectPath}] because it would cause a dependency conflict.");
|
705
710
|
return false;
|
706
711
|
}
|
707
712
|
}
|
@@ -715,7 +720,7 @@ internal static class PackageReferenceUpdater
|
|
715
720
|
{
|
716
721
|
if (await buildFile.SaveAsync())
|
717
722
|
{
|
718
|
-
logger.
|
723
|
+
logger.Info($" Saved [{buildFile.RelativePath}].");
|
719
724
|
}
|
720
725
|
}
|
721
726
|
}
|
@@ -9,6 +9,7 @@ using Microsoft.Language.Xml;
|
|
9
9
|
using NuGet.CommandLine;
|
10
10
|
|
11
11
|
using NuGetUpdater.Core.Updater;
|
12
|
+
using NuGetUpdater.Core.Utilities;
|
12
13
|
|
13
14
|
using Console = System.Console;
|
14
15
|
|
@@ -22,7 +23,7 @@ namespace NuGetUpdater.Core;
|
|
22
23
|
/// See: https://learn.microsoft.com/en-us/nuget/reference/packages-config
|
23
24
|
/// https://learn.microsoft.com/en-us/nuget/resources/check-project-format
|
24
25
|
/// <remarks>
|
25
|
-
internal static class PackagesConfigUpdater
|
26
|
+
internal static partial class PackagesConfigUpdater
|
26
27
|
{
|
27
28
|
public static async Task UpdateDependencyAsync(
|
28
29
|
string repoRootPath,
|
@@ -35,18 +36,18 @@ internal static class PackagesConfigUpdater
|
|
35
36
|
)
|
36
37
|
{
|
37
38
|
// packages.config project; use NuGet.exe to perform update
|
38
|
-
logger.
|
39
|
+
logger.Info($" Found '{ProjectHelper.PackagesConfigFileName}' project; running NuGet.exe update");
|
39
40
|
|
40
41
|
// ensure local packages directory exists
|
41
42
|
var projectBuildFile = ProjectBuildFile.Open(repoRootPath, projectPath);
|
42
43
|
var packagesSubDirectory = GetPathToPackagesDirectory(projectBuildFile, dependencyName, previousDependencyVersion, packagesConfigPath);
|
43
44
|
if (packagesSubDirectory is null)
|
44
45
|
{
|
45
|
-
logger.
|
46
|
+
logger.Info($" Project [{projectPath}] does not reference this dependency.");
|
46
47
|
return;
|
47
48
|
}
|
48
49
|
|
49
|
-
logger.
|
50
|
+
logger.Info($" Using packages directory [{packagesSubDirectory}] for project [{projectPath}].");
|
50
51
|
|
51
52
|
var projectDirectory = Path.GetDirectoryName(projectPath);
|
52
53
|
var packagesDirectory = PathHelper.JoinPath(projectDirectory, packagesSubDirectory);
|
@@ -74,7 +75,7 @@ internal static class PackagesConfigUpdater
|
|
74
75
|
"-NonInteractive",
|
75
76
|
};
|
76
77
|
|
77
|
-
logger.
|
78
|
+
logger.Info(" Finding MSBuild...");
|
78
79
|
var msbuildDirectory = MSBuildHelper.MSBuildPath;
|
79
80
|
if (msbuildDirectory is not null)
|
80
81
|
{
|
@@ -96,7 +97,7 @@ internal static class PackagesConfigUpdater
|
|
96
97
|
// Update binding redirects
|
97
98
|
await BindingRedirectManager.UpdateBindingRedirectsAsync(projectBuildFile, dependencyName, newDependencyVersion);
|
98
99
|
|
99
|
-
logger.
|
100
|
+
logger.Info(" Writing project file back to disk");
|
100
101
|
await projectBuildFile.SaveAsync();
|
101
102
|
}
|
102
103
|
|
@@ -118,12 +119,12 @@ internal static class PackagesConfigUpdater
|
|
118
119
|
var retryingAfterRestore = false;
|
119
120
|
|
120
121
|
doRestore:
|
121
|
-
logger.
|
122
|
+
logger.Info($" Running NuGet.exe with args: {string.Join(" ", updateArgs)}");
|
122
123
|
outputBuilder.Clear();
|
123
124
|
var result = Program.Main(updateArgs.ToArray());
|
124
125
|
var fullOutput = outputBuilder.ToString();
|
125
|
-
logger.
|
126
|
-
logger.
|
126
|
+
logger.Info($" Result: {result}");
|
127
|
+
logger.Info($" Output:\n{fullOutput}");
|
127
128
|
if (result != 0)
|
128
129
|
{
|
129
130
|
// The initial `update` command can fail for several reasons:
|
@@ -140,7 +141,7 @@ internal static class PackagesConfigUpdater
|
|
140
141
|
if (!retryingAfterRestore && OutputIndicatesRestoreIsRequired(fullOutput))
|
141
142
|
{
|
142
143
|
retryingAfterRestore = true;
|
143
|
-
logger.
|
144
|
+
logger.Info($" Running NuGet.exe with args: {string.Join(" ", restoreArgs)}");
|
144
145
|
outputBuilder.Clear();
|
145
146
|
var exitCodeAgain = Program.Main(restoreArgs.ToArray());
|
146
147
|
var restoreOutput = outputBuilder.ToString();
|
@@ -164,7 +165,7 @@ internal static class PackagesConfigUpdater
|
|
164
165
|
}
|
165
166
|
catch (Exception e)
|
166
167
|
{
|
167
|
-
logger.
|
168
|
+
logger.Info($"Error: {e}");
|
168
169
|
throw;
|
169
170
|
}
|
170
171
|
finally
|
@@ -178,7 +179,7 @@ internal static class PackagesConfigUpdater
|
|
178
179
|
var deltaSpawnedProcesses = currentSpawnedProcesses.Except(existingSpawnedProcesses).ToArray();
|
179
180
|
foreach (var credProvider in deltaSpawnedProcesses)
|
180
181
|
{
|
181
|
-
logger.
|
182
|
+
logger.Info($"Ending spawned credential provider process");
|
182
183
|
credProvider.Kill();
|
183
184
|
}
|
184
185
|
}
|
@@ -214,7 +215,7 @@ internal static class PackagesConfigUpdater
|
|
214
215
|
var hintPathSubString = $"{dependencyName}.{dependencyVersion}";
|
215
216
|
|
216
217
|
string? partialPathMatch = null;
|
217
|
-
var specificHintPathNodes = projectBuildFile.Contents.Descendants().Where(e => e.IsHintPathNodeForDependency(dependencyName)).ToArray();
|
218
|
+
var specificHintPathNodes = projectBuildFile.Contents.Descendants().Where(e => e.IsHintPathNodeForDependency(dependencyName, dependencyVersion)).ToArray();
|
218
219
|
foreach (var hintPathNode in specificHintPathNodes)
|
219
220
|
{
|
220
221
|
var hintPath = hintPathNode.GetContentValue();
|
@@ -265,8 +266,7 @@ internal static class PackagesConfigUpdater
|
|
265
266
|
foreach (var hintPathNode in genericHintPathNodes)
|
266
267
|
{
|
267
268
|
var hintPath = hintPathNode.GetContentValue();
|
268
|
-
var match =
|
269
|
-
// e.g., ..\..\packages \ Some.Package.1.2.3 \ lib\ net45 \ Some.Package.dll
|
269
|
+
var match = PackageAssemblyHintPathPattern().Match(hintPath);
|
270
270
|
if (match.Success)
|
271
271
|
{
|
272
272
|
partialPathMatch = match.Groups["PackagesPath"].Value;
|
@@ -296,17 +296,15 @@ internal static class PackagesConfigUpdater
|
|
296
296
|
return false;
|
297
297
|
}
|
298
298
|
|
299
|
-
private static bool IsHintPathNodeForDependency(this IXmlElementSyntax element, string dependencyName)
|
299
|
+
private static bool IsHintPathNodeForDependency(this IXmlElementSyntax element, string dependencyName, string dependencyVersion)
|
300
300
|
{
|
301
301
|
if (element.IsHintPathNode())
|
302
302
|
{
|
303
|
-
// the
|
304
|
-
//
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
if (includeAttributeValue.Equals(dependencyName, StringComparison.OrdinalIgnoreCase) ||
|
309
|
-
includeAttributeValue.StartsWith($"{dependencyName},", StringComparison.OrdinalIgnoreCase))
|
303
|
+
// the hint path will look similar to this:
|
304
|
+
// ..\packages\Some.Package.1.2.3\lib\net45\Some.Package.dll
|
305
|
+
var assemblyPath = element.GetContentValue();
|
306
|
+
var match = PackageAssemblyHintPathPattern().Match(assemblyPath);
|
307
|
+
if (match.Success)
|
310
308
|
{
|
311
309
|
return true;
|
312
310
|
}
|
@@ -325,4 +323,8 @@ internal static class PackagesConfigUpdater
|
|
325
323
|
|
326
324
|
return subpath;
|
327
325
|
}
|
326
|
+
|
327
|
+
[GeneratedRegex(@"^(?<PackagesPath>.*)[/\\](?<PackageNameAndVersion>[^/\\]+)[/\\]lib[/\\](?<Tfm>[^/\\]+)[/\\](?<AssemblyName>[^/\\]+)$", RegexOptions.IgnoreCase)]
|
328
|
+
// e.g., ..\..\packages \ Some.Package.1.2.3 \ lib \ net45 \ Some.Package.dll
|
329
|
+
private static partial Regex PackageAssemblyHintPathPattern();
|
328
330
|
}
|
@@ -4,6 +4,7 @@ using System.Text.Json.Serialization;
|
|
4
4
|
|
5
5
|
using NuGetUpdater.Core.Analyze;
|
6
6
|
using NuGetUpdater.Core.Updater;
|
7
|
+
using NuGetUpdater.Core.Utilities;
|
7
8
|
|
8
9
|
namespace NuGetUpdater.Core;
|
9
10
|
|
@@ -114,11 +115,11 @@ public class UpdaterWorker : IUpdaterWorker
|
|
114
115
|
await RunForProjectAsync(repoRootPath, workspacePath, dependencyName, previousDependencyVersion, newDependencyVersion, isTransitive);
|
115
116
|
break;
|
116
117
|
default:
|
117
|
-
_logger.
|
118
|
+
_logger.Info($"File extension [{extension}] is not supported.");
|
118
119
|
break;
|
119
120
|
}
|
120
121
|
|
121
|
-
_logger.
|
122
|
+
_logger.Info("Update complete.");
|
122
123
|
|
123
124
|
_processedProjectPaths.Clear();
|
124
125
|
return new UpdateOperationResult();
|
@@ -126,7 +127,7 @@ public class UpdaterWorker : IUpdaterWorker
|
|
126
127
|
|
127
128
|
internal static async Task WriteResultFile(UpdateOperationResult result, string resultOutputPath, ILogger logger)
|
128
129
|
{
|
129
|
-
logger.
|
130
|
+
logger.Info($" Writing update result to [{resultOutputPath}].");
|
130
131
|
|
131
132
|
var resultJson = JsonSerializer.Serialize(result, SerializerOptions);
|
132
133
|
await File.WriteAllTextAsync(resultOutputPath, resultJson);
|
@@ -140,7 +141,7 @@ public class UpdaterWorker : IUpdaterWorker
|
|
140
141
|
string newDependencyVersion,
|
141
142
|
bool isTransitive)
|
142
143
|
{
|
143
|
-
_logger.
|
144
|
+
_logger.Info($"Running for solution [{Path.GetRelativePath(repoRootPath, solutionPath)}]");
|
144
145
|
var projectPaths = MSBuildHelper.GetProjectPathsFromSolution(solutionPath);
|
145
146
|
foreach (var projectPath in projectPaths)
|
146
147
|
{
|
@@ -156,10 +157,10 @@ public class UpdaterWorker : IUpdaterWorker
|
|
156
157
|
string newDependencyVersion,
|
157
158
|
bool isTransitive)
|
158
159
|
{
|
159
|
-
_logger.
|
160
|
+
_logger.Info($"Running for proj file [{Path.GetRelativePath(repoRootPath, projFilePath)}]");
|
160
161
|
if (!File.Exists(projFilePath))
|
161
162
|
{
|
162
|
-
_logger.
|
163
|
+
_logger.Info($"File [{projFilePath}] does not exist.");
|
163
164
|
return;
|
164
165
|
}
|
165
166
|
|
@@ -182,10 +183,10 @@ public class UpdaterWorker : IUpdaterWorker
|
|
182
183
|
string newDependencyVersion,
|
183
184
|
bool isTransitive)
|
184
185
|
{
|
185
|
-
_logger.
|
186
|
+
_logger.Info($"Running for project file [{Path.GetRelativePath(repoRootPath, projectPath)}]");
|
186
187
|
if (!File.Exists(projectPath))
|
187
188
|
{
|
188
|
-
_logger.
|
189
|
+
_logger.Info($"File [{projectPath}] does not exist.");
|
189
190
|
return;
|
190
191
|
}
|
191
192
|
|
@@ -215,18 +216,21 @@ public class UpdaterWorker : IUpdaterWorker
|
|
215
216
|
|
216
217
|
_processedProjectPaths.Add(projectPath);
|
217
218
|
|
218
|
-
_logger.
|
219
|
+
_logger.Info($"Updating project [{projectPath}]");
|
219
220
|
|
220
|
-
|
221
|
+
var additionalFiles = ProjectHelper.GetAllAdditionalFilesFromProject(projectPath, ProjectHelper.PathFormat.Full);
|
222
|
+
var packagesConfigFullPath = additionalFiles.Where(p => Path.GetFileName(p).Equals(ProjectHelper.PackagesConfigFileName, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
|
223
|
+
if (packagesConfigFullPath is not null)
|
221
224
|
{
|
222
|
-
await PackagesConfigUpdater.UpdateDependencyAsync(repoRootPath, projectPath, dependencyName, previousDependencyVersion, newDependencyVersion,
|
225
|
+
await PackagesConfigUpdater.UpdateDependencyAsync(repoRootPath, projectPath, dependencyName, previousDependencyVersion, newDependencyVersion, packagesConfigFullPath, _logger);
|
223
226
|
}
|
224
227
|
|
225
228
|
// Some repos use a mix of packages.config and PackageReference
|
226
229
|
await PackageReferenceUpdater.UpdateDependencyAsync(repoRootPath, projectPath, dependencyName, previousDependencyVersion, newDependencyVersion, isTransitive, _experimentsManager, _logger);
|
227
230
|
|
228
231
|
// Update lock file if exists
|
229
|
-
|
232
|
+
var packagesLockFullPath = additionalFiles.Where(p => Path.GetFileName(p).Equals(ProjectHelper.PackagesLockJsonFileName, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
|
233
|
+
if (packagesLockFullPath is not null)
|
230
234
|
{
|
231
235
|
await LockFileUpdater.UpdateLockFileAsync(repoRootPath, projectPath, _logger);
|
232
236
|
}
|