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.
- checksums.yaml +4 -4
- data/helpers/lib/NuGetUpdater/.gitignore +1 -0
- data/helpers/lib/NuGetUpdater/Directory.Build.targets +17 -0
- data/helpers/lib/NuGetUpdater/Directory.Packages.props +26 -17
- data/helpers/lib/NuGetUpdater/NuGetProjects/NuGet.Packaging/NuGet.Packaging.csproj +0 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/DiscoverCommand.cs +7 -3
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/RunCommand.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Analyze.cs +3 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Discover.cs +88 -47
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/AnalyzeWorker.cs +31 -16
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/CompatabilityChecker.cs +1 -1
- 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/DependencyDiscovery.props +7 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/DependencyDiscovery.targets +10 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DiscoveryWorker.cs +64 -53
- 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 +17 -5
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/PackagesConfigDiscoveryResult.cs +3 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/ProjectDiscoveryResult.cs +3 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/SdkProjectDiscovery.cs +429 -12
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/WorkspaceDiscoveryResult.cs +0 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/ExperimentsManager.cs +12 -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/NuGetUpdater.Core.csproj +7 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/Job.cs +23 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/RunWorker.cs +43 -58
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/TargetFrameworkReporter.targets +13 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/BindingRedirectManager.cs +13 -43
- 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 +3 -10
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/PackageReferenceUpdater.cs +40 -33
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/PackagesConfigUpdater.cs +12 -11
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/UpdaterWorker.cs +16 -12
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/CollectionExtensions.cs +17 -0
- 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/MSBuildHelper.cs +74 -20
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/NuGetHelper.cs +1 -17
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/PathComparer.cs +31 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/PathHelper.cs +46 -10
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/ProjectHelper.cs +96 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Analyze/AnalyzeWorkerTests.cs +135 -3
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTestBase.cs +71 -38
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.PackagesConfig.cs +66 -4
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.Proj.cs +11 -5
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.Project.cs +808 -222
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.cs +477 -97
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/ExpectedDiscoveryResults.cs +5 -9
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/SdkProjectDiscoveryTests.cs +494 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/MockNuGetPackage.cs +46 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/NuGetUpdater.Core.Test.csproj +0 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/RunWorkerTests.cs +401 -77
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/SerializationTests.cs +35 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/UpdatedDependencyListTests.cs +60 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/TemporaryDirectory.cs +3 -2
- 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/UpdateWorkerTestBase.cs +8 -4
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackageReference.cs +40 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackagesConfig.cs +1 -1
- 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 +8 -5
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/PathHelperTests.cs +49 -3
- data/lib/dependabot/nuget/analysis/analysis_json_reader.rb +3 -1
- data/lib/dependabot/nuget/file_fetcher.rb +12 -393
- data/lib/dependabot/nuget/file_parser.rb +23 -54
- data/lib/dependabot/nuget/file_updater.rb +21 -16
- data/lib/dependabot/nuget/native_discovery/native_dependency_file_discovery.rb +2 -9
- data/lib/dependabot/nuget/native_discovery/native_discovery_json_reader.rb +183 -80
- data/lib/dependabot/nuget/native_discovery/native_project_discovery.rb +25 -3
- data/lib/dependabot/nuget/native_discovery/native_workspace_discovery.rb +1 -11
- data/lib/dependabot/nuget/native_helpers.rb +13 -4
- data/lib/dependabot/nuget/native_update_checker/native_update_checker.rb +17 -4
- metadata +15 -12
- data/helpers/lib/NuGetUpdater/NuGetProjects/Directory.Packages.props +0 -29
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/RequirementConverter.cs +0 -17
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DirectoryPackagesPropsDiscovery.cs +0 -69
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DirectoryPackagesPropsDiscoveryResult.cs +0 -11
- 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/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.
|
117
|
-
_logger.
|
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
|
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
|
-
|
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.
|
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
|
245
|
-
async Task AddUpdatedFileIfDifferentAsync(string directory, string fileName
|
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
|
-
|
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
|
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
|
-
|
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 =
|
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
|
347
|
-
|
348
|
-
if (File.Exists(pathToPackagesConfig))
|
327
|
+
foreach (var extraFile in project.ImportedFiles.Concat(project.AdditionalFiles))
|
349
328
|
{
|
350
|
-
|
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 =
|
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 =
|
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(
|
129
|
+
private static async ValueTask<ConfigurationFile?> TryGetRuntimeConfigurationFile(string fullProjectPath)
|
128
130
|
{
|
129
|
-
var
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
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 (
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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
|
}
|