dependabot-nuget 0.287.0 → 0.289.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. checksums.yaml +4 -4
  2. data/helpers/lib/NuGetUpdater/.gitignore +1 -0
  3. data/helpers/lib/NuGetUpdater/Directory.Build.targets +17 -0
  4. data/helpers/lib/NuGetUpdater/Directory.Packages.props +26 -17
  5. data/helpers/lib/NuGetUpdater/NuGetProjects/NuGet.Packaging/NuGet.Packaging.csproj +0 -1
  6. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/DiscoverCommand.cs +7 -3
  7. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/RunCommand.cs +1 -1
  8. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Analyze.cs +3 -1
  9. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Discover.cs +88 -47
  10. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/AnalyzeWorker.cs +31 -16
  11. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/CompatabilityChecker.cs +1 -1
  12. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/RequirementArrayConverter.cs +39 -0
  13. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/VersionFinder.cs +1 -1
  14. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Clone/ShellGitCommandHandler.cs +1 -1
  15. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/DependencyDiscovery.props +7 -0
  16. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/DependencyDiscovery.targets +10 -0
  17. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DiscoveryWorker.cs +64 -53
  18. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DotNetToolsJsonDiscovery.cs +2 -2
  19. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/GlobalJsonDiscovery.cs +2 -2
  20. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/PackagesConfigDiscovery.cs +17 -5
  21. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/PackagesConfigDiscoveryResult.cs +3 -1
  22. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/ProjectDiscoveryResult.cs +3 -0
  23. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/SdkProjectDiscovery.cs +429 -12
  24. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/WorkspaceDiscoveryResult.cs +0 -1
  25. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/ExperimentsManager.cs +12 -2
  26. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/JsonBuildFile.cs +1 -1
  27. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/FrameworkChecker/CompatabilityChecker.cs +2 -2
  28. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/NuGetUpdater.Core.csproj +7 -2
  29. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/Job.cs +23 -0
  30. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/RunWorker.cs +43 -58
  31. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/TargetFrameworkReporter.targets +13 -0
  32. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/BindingRedirectManager.cs +13 -43
  33. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/DotNetToolsJsonUpdater.cs +4 -4
  34. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/GlobalJsonUpdater.cs +5 -5
  35. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/LockFileUpdater.cs +3 -10
  36. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/PackageReferenceUpdater.cs +40 -33
  37. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/PackagesConfigUpdater.cs +12 -11
  38. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/UpdaterWorker.cs +16 -12
  39. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/CollectionExtensions.cs +17 -0
  40. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/ConsoleLogger.cs +1 -1
  41. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/DependencyConflictResolver.cs +19 -19
  42. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/ILogger.cs +11 -1
  43. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/MSBuildHelper.cs +74 -20
  44. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/NuGetHelper.cs +1 -17
  45. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/PathComparer.cs +31 -0
  46. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/PathHelper.cs +46 -10
  47. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/ProjectHelper.cs +96 -0
  48. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Analyze/AnalyzeWorkerTests.cs +135 -3
  49. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTestBase.cs +71 -38
  50. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.PackagesConfig.cs +66 -4
  51. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.Proj.cs +11 -5
  52. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.Project.cs +808 -222
  53. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.cs +477 -97
  54. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/ExpectedDiscoveryResults.cs +5 -9
  55. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/SdkProjectDiscoveryTests.cs +494 -0
  56. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/MockNuGetPackage.cs +46 -1
  57. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/NuGetUpdater.Core.Test.csproj +0 -1
  58. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/RunWorkerTests.cs +401 -77
  59. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/SerializationTests.cs +35 -2
  60. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/UpdatedDependencyListTests.cs +60 -2
  61. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/TemporaryDirectory.cs +3 -2
  62. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/TestLogger.cs +1 -1
  63. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/BindingRedirectsTests.cs +1 -1
  64. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTestBase.cs +8 -4
  65. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackageReference.cs +40 -0
  66. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackagesConfig.cs +1 -1
  67. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/AssertEx.cs +1 -1
  68. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/LinuxOnlyAttribute.cs +12 -0
  69. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/MSBuildHelperTests.cs +8 -5
  70. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/PathHelperTests.cs +49 -3
  71. data/lib/dependabot/nuget/analysis/analysis_json_reader.rb +3 -1
  72. data/lib/dependabot/nuget/file_fetcher.rb +12 -393
  73. data/lib/dependabot/nuget/file_parser.rb +23 -54
  74. data/lib/dependabot/nuget/file_updater.rb +21 -16
  75. data/lib/dependabot/nuget/native_discovery/native_dependency_file_discovery.rb +2 -9
  76. data/lib/dependabot/nuget/native_discovery/native_discovery_json_reader.rb +183 -80
  77. data/lib/dependabot/nuget/native_discovery/native_project_discovery.rb +25 -3
  78. data/lib/dependabot/nuget/native_discovery/native_workspace_discovery.rb +1 -11
  79. data/lib/dependabot/nuget/native_helpers.rb +13 -4
  80. data/lib/dependabot/nuget/native_update_checker/native_update_checker.rb +17 -4
  81. metadata +15 -12
  82. data/helpers/lib/NuGetUpdater/NuGetProjects/Directory.Packages.props +0 -29
  83. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/RequirementConverter.cs +0 -17
  84. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DirectoryPackagesPropsDiscovery.cs +0 -69
  85. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DirectoryPackagesPropsDiscoveryResult.cs +0 -11
  86. data/lib/dependabot/nuget/file_fetcher/import_paths_finder.rb +0 -73
  87. data/lib/dependabot/nuget/file_fetcher/sln_project_paths_finder.rb +0 -60
  88. data/lib/dependabot/nuget/native_discovery/native_directory_packages_props_discovery.rb +0 -44
@@ -113,8 +113,8 @@ public class RunWorker
113
113
  {
114
114
  var discoveryResult = await _discoveryWorker.RunAsync(repoContentsPath.FullName, repoDirectory);
115
115
 
116
- _logger.Log("Discovery JSON content:");
117
- _logger.Log(JsonSerializer.Serialize(discoveryResult, DiscoveryWorker.SerializerOptions));
116
+ _logger.Info("Discovery JSON content:");
117
+ _logger.Info(JsonSerializer.Serialize(discoveryResult, DiscoveryWorker.SerializerOptions));
118
118
 
119
119
  // report dependencies
120
120
  var discoveredUpdatedDependencies = GetUpdatedDependencyListFromDiscovery(discoveryResult, repoContentsPath.FullName);
@@ -134,35 +134,28 @@ public class RunWorker
134
134
  });
135
135
 
136
136
  // track original contents for later handling
137
- async Task TrackOriginalContentsAsync(string directory, string fileName, string? replacementFileName = null)
137
+ async Task TrackOriginalContentsAsync(string directory, string fileName)
138
138
  {
139
- var repoFullPath = Path.Join(directory, fileName);
140
- if (replacementFileName is not null)
141
- {
142
- repoFullPath = Path.Join(Path.GetDirectoryName(repoFullPath)!, replacementFileName);
143
- }
144
-
145
- repoFullPath = repoFullPath.FullyNormalizedRootedPath();
139
+ var repoFullPath = Path.Join(directory, fileName).FullyNormalizedRootedPath();
146
140
  var localFullPath = Path.Join(repoContentsPath.FullName, repoFullPath);
147
-
148
- if (!File.Exists(localFullPath))
149
- {
150
- return;
151
- }
152
-
153
141
  var content = await File.ReadAllTextAsync(localFullPath);
154
142
  originalDependencyFileContents[repoFullPath] = content;
155
143
  }
156
144
 
157
145
  foreach (var project in discoveryResult.Projects)
158
146
  {
147
+ var projectDirectory = Path.GetDirectoryName(project.FilePath);
159
148
  await TrackOriginalContentsAsync(discoveryResult.Path, project.FilePath);
160
- await TrackOriginalContentsAsync(discoveryResult.Path, project.FilePath, replacementFileName: "packages.config");
149
+ foreach (var extraFile in project.ImportedFiles.Concat(project.AdditionalFiles))
150
+ {
151
+ var extraFilePath = Path.Join(projectDirectory, extraFile);
152
+ await TrackOriginalContentsAsync(discoveryResult.Path, extraFilePath);
153
+ }
161
154
  // TODO: include global.json, etc.
162
155
  }
163
156
 
164
157
  // do update
165
- _logger.Log($"Running update in directory {repoDirectory}");
158
+ _logger.Info($"Running update in directory {repoDirectory}");
166
159
  foreach (var project in discoveryResult.Projects)
167
160
  {
168
161
  foreach (var dependency in project.Dependencies.Where(d => !d.IsTransitive))
@@ -192,13 +185,7 @@ public class RunWorker
192
185
  // TODO: log analysisResult
193
186
  if (analysisResult.CanUpdate)
194
187
  {
195
- var dependencyLocation = Path.Join(discoveryResult.Path, project.FilePath);
196
- if (dependency.Type == DependencyType.PackagesConfig)
197
- {
198
- dependencyLocation = Path.Join(Path.GetDirectoryName(dependencyLocation)!, "packages.config");
199
- }
200
-
201
- dependencyLocation = dependencyLocation.FullyNormalizedRootedPath();
188
+ var dependencyLocation = Path.Join(discoveryResult.Path, project.FilePath).FullyNormalizedRootedPath();
202
189
 
203
190
  // TODO: this is inefficient, but not likely causing a bottleneck
204
191
  var previousDependency = discoveredUpdatedDependencies.Dependencies
@@ -241,48 +228,46 @@ public class RunWorker
241
228
  }
242
229
 
243
230
  // create PR - we need to manually check file contents; we can't easily use `git status` in tests
244
- var updatedDependencyFiles = new List<DependencyFile>();
245
- async Task AddUpdatedFileIfDifferentAsync(string directory, string fileName, string? replacementFileName = null)
231
+ var updatedDependencyFiles = new Dictionary<string, DependencyFile>();
232
+ async Task AddUpdatedFileIfDifferentAsync(string directory, string fileName)
246
233
  {
247
- var repoFullPath = Path.Join(directory, fileName);
248
- if (replacementFileName is not null)
249
- {
250
- repoFullPath = Path.Join(Path.GetDirectoryName(repoFullPath)!, replacementFileName);
251
- }
252
-
253
- repoFullPath = repoFullPath.FullyNormalizedRootedPath();
254
- var localFullPath = Path.Join(repoContentsPath.FullName, repoFullPath);
255
-
256
- if (!File.Exists(localFullPath))
257
- {
258
- return;
259
- }
260
-
234
+ var repoFullPath = Path.Join(directory, fileName).FullyNormalizedRootedPath();
235
+ var localFullPath = Path.GetFullPath(Path.Join(repoContentsPath.FullName, repoFullPath));
261
236
  var originalContent = originalDependencyFileContents[repoFullPath];
262
237
  var updatedContent = await File.ReadAllTextAsync(localFullPath);
263
238
  if (updatedContent != originalContent)
264
239
  {
265
- updatedDependencyFiles.Add(new DependencyFile()
240
+ updatedDependencyFiles[localFullPath] = new DependencyFile()
266
241
  {
267
242
  Name = Path.GetFileName(repoFullPath),
268
243
  Directory = Path.GetDirectoryName(repoFullPath)!.NormalizePathToUnix(),
269
244
  Content = updatedContent,
270
- });
245
+ };
271
246
  }
272
247
  }
273
248
 
274
249
  foreach (var project in discoveryResult.Projects)
275
250
  {
276
251
  await AddUpdatedFileIfDifferentAsync(discoveryResult.Path, project.FilePath);
277
- await AddUpdatedFileIfDifferentAsync(discoveryResult.Path, project.FilePath, replacementFileName: "packages.config");
252
+ var projectDirectory = Path.GetDirectoryName(project.FilePath);
253
+ foreach (var extraFile in project.ImportedFiles.Concat(project.AdditionalFiles))
254
+ {
255
+ var extraFilePath = Path.Join(projectDirectory, extraFile);
256
+ await AddUpdatedFileIfDifferentAsync(discoveryResult.Path, extraFilePath);
257
+ }
258
+ // TODO: handle global.json, etc.
278
259
  }
279
260
 
280
261
  if (updatedDependencyFiles.Count > 0)
281
262
  {
263
+ var updatedDependencyFileList = updatedDependencyFiles
264
+ .OrderBy(kvp => kvp.Key)
265
+ .Select(kvp => kvp.Value)
266
+ .ToArray();
282
267
  var createPullRequest = new CreatePullRequest()
283
268
  {
284
269
  Dependencies = actualUpdatedDependencies.ToArray(),
285
- UpdatedDependencyFiles = updatedDependencyFiles.ToArray(),
270
+ UpdatedDependencyFiles = updatedDependencyFileList,
286
271
  BaseCommitSha = baseCommitSha,
287
272
  CommitMessage = "TODO: message",
288
273
  PrTitle = "TODO: title",
@@ -303,7 +288,7 @@ public class RunWorker
303
288
 
304
289
  var result = new RunResult()
305
290
  {
306
- Base64DependencyFiles = originalDependencyFileContents.Select(kvp =>
291
+ Base64DependencyFiles = originalDependencyFileContents.OrderBy(kvp => kvp.Key).Select(kvp =>
307
292
  {
308
293
  var fullPath = kvp.Key.FullyNormalizedRootedPath();
309
294
  return new DependencyFile()
@@ -335,22 +320,24 @@ public class RunWorker
335
320
  {
336
321
  auxiliaryFiles.Add(GetFullRepoPath(discoveryResult.DotNetToolsJson.FilePath));
337
322
  }
338
- if (discoveryResult.DirectoryPackagesProps is not null)
339
- {
340
- auxiliaryFiles.Add(GetFullRepoPath(discoveryResult.DirectoryPackagesProps.FilePath));
341
- }
342
323
 
343
324
  foreach (var project in discoveryResult.Projects)
344
325
  {
345
326
  var projectDirectory = Path.GetDirectoryName(project.FilePath);
346
- var pathToPackagesConfig = Path.Join(pathToContents, discoveryResult.Path, projectDirectory, "packages.config");
347
-
348
- if (File.Exists(pathToPackagesConfig))
327
+ foreach (var extraFile in project.ImportedFiles.Concat(project.AdditionalFiles))
349
328
  {
350
- auxiliaryFiles.Add(GetFullRepoPath(Path.Join(projectDirectory, "packages.config")));
329
+ var extraFileFullPath = Path.Join(projectDirectory, extraFile);
330
+ var extraFileRepoPath = GetFullRepoPath(extraFileFullPath);
331
+ auxiliaryFiles.Add(extraFileRepoPath);
351
332
  }
352
333
  }
353
334
 
335
+ var dependencyFiles = discoveryResult.Projects
336
+ .Select(p => GetFullRepoPath(p.FilePath))
337
+ .Concat(auxiliaryFiles)
338
+ .Distinct()
339
+ .OrderBy(p => p)
340
+ .ToArray();
354
341
  var updatedDependencyList = new UpdatedDependencyList()
355
342
  {
356
343
  Dependencies = discoveryResult.Projects.SelectMany(p =>
@@ -361,9 +348,7 @@ public class RunWorker
361
348
  Name = d.Name,
362
349
  Requirements = d.IsTransitive ? [] : [new ReportedRequirement()
363
350
  {
364
- File = d.Type == DependencyType.PackagesConfig
365
- ? Path.Join(Path.GetDirectoryName(GetFullRepoPath(p.FilePath))!, "packages.config").FullyNormalizedRootedPath()
366
- : GetFullRepoPath(p.FilePath),
351
+ File = GetFullRepoPath(p.FilePath),
367
352
  Requirement = d.Version!,
368
353
  Groups = ["dependencies"],
369
354
  }],
@@ -371,7 +356,7 @@ public class RunWorker
371
356
  }
372
357
  );
373
358
  }).ToArray(),
374
- DependencyFiles = discoveryResult.Projects.Select(p => GetFullRepoPath(p.FilePath)).Concat(auxiliaryFiles).ToArray(),
359
+ DependencyFiles = dependencyFiles,
375
360
  };
376
361
  return updatedDependencyList;
377
362
  }
@@ -0,0 +1,13 @@
1
+ <Project>
2
+ <Import Project="DependencyDiscovery.props" />
3
+
4
+ <Target Name="ReportTargetFramework">
5
+ <!-- this property is for non-SDK projects, commonly with `packages.config -->
6
+ <!-- e.g., returns ".NETFramework,Version=v4.5" -->
7
+ <Message Text="ProjectData::TargetFrameworkVersion=$(TargetFrameworkIdentifier),Version=$(TargetFrameworkVersion)" Importance="High" Condition="'$(TargetFrameworkIdentifier)' != '' AND '' != '$(TargetFrameworkVersion)'" />
8
+
9
+ <!-- these properties are for SDK projects -->
10
+ <Message Text="ProjectData::TargetFramework=$(TargetFramework)" Importance="High" Condition="'$(TargetFramework)' != ''" />
11
+ <Message Text="ProjectData::TargetFrameworks=$(TargetFrameworks)" Importance="High" Condition="'$(TargetFrameworks)' != ''" />
12
+ </Target>
13
+ </Project>
@@ -8,6 +8,8 @@ using Microsoft.Language.Xml;
8
8
 
9
9
  using NuGet.ProjectManagement;
10
10
 
11
+ using NuGetUpdater.Core.Utilities;
12
+
11
13
  using Runtime_AssemblyBinding = CoreV2::NuGet.Runtime.AssemblyBinding;
12
14
 
13
15
  namespace NuGetUpdater.Core;
@@ -32,7 +34,7 @@ internal static class BindingRedirectManager
32
34
  /// <param name="updatedPackageVersion">The version of the package that was updated</param>
33
35
  public static async ValueTask UpdateBindingRedirectsAsync(ProjectBuildFile projectBuildFile, string updatedPackageName, string updatedPackageVersion)
34
36
  {
35
- var configFile = await TryGetRuntimeConfigurationFile(projectBuildFile);
37
+ var configFile = await TryGetRuntimeConfigurationFile(projectBuildFile.Path);
36
38
  if (configFile is null)
37
39
  {
38
40
  // no runtime config file so no need to add binding redirects
@@ -124,56 +126,24 @@ internal static class BindingRedirectManager
124
126
  }
125
127
  }
126
128
 
127
- private static async ValueTask<ConfigurationFile?> TryGetRuntimeConfigurationFile(ProjectBuildFile projectBuildFile)
129
+ private static async ValueTask<ConfigurationFile?> TryGetRuntimeConfigurationFile(string fullProjectPath)
128
130
  {
129
- var directoryPath = Path.GetDirectoryName(projectBuildFile.Path);
130
- if (directoryPath is null)
131
- {
132
- return null;
133
- }
134
-
135
- var configFile = projectBuildFile.ItemNodes
136
- .Where(IsConfigFile)
137
- .FirstOrDefault();
131
+ var additionalFiles = ProjectHelper.GetAdditionalFilesFromProjectContent(fullProjectPath, ProjectHelper.PathFormat.Full);
132
+ var configFilePath = additionalFiles
133
+ .FirstOrDefault(p =>
134
+ {
135
+ var fileName = Path.GetFileName(p);
136
+ return fileName.Equals(ProjectHelper.AppConfigFileName, StringComparison.OrdinalIgnoreCase)
137
+ || fileName.Equals(ProjectHelper.WebConfigFileName, StringComparison.OrdinalIgnoreCase);
138
+ });
138
139
 
139
- if (configFile is null)
140
+ if (configFilePath is null)
140
141
  {
141
142
  return null;
142
143
  }
143
144
 
144
- var configFilePath = Path.GetFullPath(Path.Combine(directoryPath, GetValue(configFile)));
145
145
  var configFileContents = await File.ReadAllTextAsync(configFilePath);
146
146
  return new ConfigurationFile(configFilePath, configFileContents, false);
147
-
148
- static string GetValue(IXmlElementSyntax element)
149
- {
150
- var content = element.GetAttributeValue("Include");
151
- if (!string.IsNullOrEmpty(content))
152
- {
153
- return content;
154
- }
155
-
156
- content = element.GetContentValue();
157
- if (!string.IsNullOrEmpty(content))
158
- {
159
- return content;
160
- }
161
-
162
- return string.Empty;
163
- }
164
-
165
- static bool IsConfigFile(IXmlElementSyntax element)
166
- {
167
- var content = GetValue(element);
168
- if (content is null)
169
- {
170
- return false;
171
- }
172
-
173
- var path = Path.GetFileName(content);
174
- return (element.Name == "None" && string.Equals(path, "app.config", StringComparison.OrdinalIgnoreCase))
175
- || (element.Name == "Content" && string.Equals(path, "web.config", StringComparison.OrdinalIgnoreCase));
176
- }
177
147
  }
178
148
 
179
149
  private static string AddBindingRedirects(ConfigurationFile configFile, IEnumerable<(Runtime_AssemblyBinding Binding, string AssemblyPath)> bindingRedirectsAndAssemblyPaths, string assemblyPathPrefix)
@@ -12,18 +12,18 @@ internal static class DotNetToolsJsonUpdater
12
12
  {
13
13
  if (!MSBuildHelper.TryGetDotNetToolsJsonPath(repoRootPath, workspacePath, out var dotnetToolsJsonPath))
14
14
  {
15
- logger.Log(" No dotnet-tools.json file found.");
15
+ logger.Info(" No dotnet-tools.json file found.");
16
16
  return;
17
17
  }
18
18
 
19
19
  var dotnetToolsJsonFile = DotNetToolsJsonBuildFile.Open(repoRootPath, dotnetToolsJsonPath, logger);
20
20
 
21
- logger.Log($" Updating [{dotnetToolsJsonFile.RelativePath}] file.");
21
+ logger.Info($" Updating [{dotnetToolsJsonFile.RelativePath}] file.");
22
22
 
23
23
  var containsDependency = dotnetToolsJsonFile.GetDependencies().Any(d => d.Name.Equals(dependencyName, StringComparison.OrdinalIgnoreCase));
24
24
  if (!containsDependency)
25
25
  {
26
- logger.Log($" Dependency [{dependencyName}] not found.");
26
+ logger.Info($" Dependency [{dependencyName}] not found.");
27
27
  return;
28
28
  }
29
29
 
@@ -39,7 +39,7 @@ internal static class DotNetToolsJsonUpdater
39
39
 
40
40
  if (await dotnetToolsJsonFile.SaveAsync())
41
41
  {
42
- logger.Log($" Saved [{dotnetToolsJsonFile.RelativePath}].");
42
+ logger.Info($" Saved [{dotnetToolsJsonFile.RelativePath}].");
43
43
  }
44
44
  }
45
45
  }
@@ -12,25 +12,25 @@ internal static class GlobalJsonUpdater
12
12
  {
13
13
  if (!MSBuildHelper.TryGetGlobalJsonPath(repoRootPath, workspacePath, out var globalJsonPath))
14
14
  {
15
- logger.Log(" No global.json file found.");
15
+ logger.Info(" No global.json file found.");
16
16
  return;
17
17
  }
18
18
 
19
19
  var globalJsonFile = GlobalJsonBuildFile.Open(repoRootPath, globalJsonPath, logger);
20
20
 
21
- logger.Log($" Updating [{globalJsonFile.RelativePath}] file.");
21
+ logger.Info($" Updating [{globalJsonFile.RelativePath}] file.");
22
22
 
23
23
  var containsDependency = globalJsonFile.GetDependencies().Any(d => d.Name.Equals(dependencyName, StringComparison.OrdinalIgnoreCase));
24
24
  if (!containsDependency)
25
25
  {
26
- logger.Log($" Dependency [{dependencyName}] not found.");
26
+ logger.Info($" Dependency [{dependencyName}] not found.");
27
27
  return;
28
28
  }
29
29
 
30
30
  if (globalJsonFile.MSBuildSdks?.TryGetPropertyValue(dependencyName, out var version) != true
31
31
  || version?.GetValue<string>() is not string versionString)
32
32
  {
33
- logger.Log(" Unable to determine dependency version.");
33
+ logger.Info(" Unable to determine dependency version.");
34
34
  return;
35
35
  }
36
36
 
@@ -43,7 +43,7 @@ internal static class GlobalJsonUpdater
43
43
 
44
44
  if (await globalJsonFile.SaveAsync())
45
45
  {
46
- logger.Log($" Saved [{globalJsonFile.RelativePath}].");
46
+ logger.Info($" Saved [{globalJsonFile.RelativePath}].");
47
47
  }
48
48
  }
49
49
  }
@@ -7,22 +7,15 @@ internal static class LockFileUpdater
7
7
  string projectPath,
8
8
  ILogger logger)
9
9
  {
10
- var projectDirectory = Path.GetDirectoryName(projectPath);
11
- var lockPath = Path.Combine(projectDirectory, "packages.lock.json");
12
- logger.Log($" Updating lock file");
13
- if (!File.Exists(lockPath))
14
- {
15
- logger.Log($" File [{Path.GetRelativePath(repoRootPath, lockPath)}] does not exist.");
16
- return;
17
- }
18
-
10
+ var projectDirectory = Path.GetDirectoryName(projectPath)!;
19
11
  await MSBuildHelper.SidelineGlobalJsonAsync(projectDirectory, repoRootPath, async () =>
20
12
  {
21
13
  var (exitCode, stdout, stderr) = await ProcessEx.RunAsync("dotnet", ["restore", "--force-evaluate", projectPath], workingDirectory: projectDirectory);
22
14
  if (exitCode != 0)
23
15
  {
24
- logger.Log($" Lock file update failed.\nSTDOUT:\n{stdout}\nSTDERR:\n{stderr}");
16
+ logger.Error($" Lock file update failed.\nSTDOUT:\n{stdout}\nSTDERR:\n{stderr}");
25
17
  }
18
+ return (exitCode, stdout, stderr);
26
19
  }, logger, retainMSBuildSdks: true);
27
20
  }
28
21
  }