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
@@ -62,7 +62,7 @@ internal static class VersionFinder
|
|
62
62
|
var feed = await sourceRepository.GetResourceAsync<MetadataResource>();
|
63
63
|
if (feed is null)
|
64
64
|
{
|
65
|
-
logger.
|
65
|
+
logger.Warn($"Failed to get MetadataResource for [{source.Source}]");
|
66
66
|
continue;
|
67
67
|
}
|
68
68
|
|
@@ -13,7 +13,7 @@ public class ShellGitCommandHandler : IGitCommandHandler
|
|
13
13
|
|
14
14
|
public async Task RunGitCommandAsync(IReadOnlyCollection<string> args, string? workingDirectory = null)
|
15
15
|
{
|
16
|
-
_logger.
|
16
|
+
_logger.Info($"Running command: git {string.Join(" ", args)}{(workingDirectory is null ? "" : $" in directory {workingDirectory}")}");
|
17
17
|
var (exitCode, stdout, stderr) = await ProcessEx.RunAsync("git", args, workingDirectory);
|
18
18
|
HandleErrorsFromOutput(stdout, stderr);
|
19
19
|
}
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<Project>
|
2
|
+
<!-- The following properties enable target framework and dependency discovery when OS-specific workloads are required -->
|
3
|
+
<PropertyGroup>
|
4
|
+
<DesignTimeBuild>true</DesignTimeBuild>
|
5
|
+
<TargetPlatformVersion Condition=" $(TargetFramework.Contains('-')) ">1.0</TargetPlatformVersion>
|
6
|
+
</PropertyGroup>
|
7
|
+
</Project>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<Project>
|
2
|
+
<Import Project="DependencyDiscovery.props" />
|
3
|
+
|
4
|
+
<Target Name="_DiscoverDependencies" DependsOnTargets="GenerateBuildDependencyFile;ResolvePackageAssets">
|
5
|
+
<!--
|
6
|
+
The target GenerateBuildDependencyFile is sufficient for projects targeting .NET Standard or .NET Core.
|
7
|
+
The target ResolvePackageAssets is necessary for projects targeting .NET Framework.
|
8
|
+
-->
|
9
|
+
</Target>
|
10
|
+
</Project>
|
@@ -16,8 +16,9 @@ public partial class DiscoveryWorker : IDiscoveryWorker
|
|
16
16
|
{
|
17
17
|
public const string DiscoveryResultFileName = "./.dependabot/discovery.json";
|
18
18
|
|
19
|
+
private readonly ExperimentsManager _experimentsManager;
|
19
20
|
private readonly ILogger _logger;
|
20
|
-
private readonly HashSet<string> _processedProjectPaths = new(StringComparer.
|
21
|
+
private readonly HashSet<string> _processedProjectPaths = new(StringComparer.Ordinal); private readonly HashSet<string> _restoredMSBuildSdks = new(StringComparer.OrdinalIgnoreCase);
|
21
22
|
|
22
23
|
internal static readonly JsonSerializerOptions SerializerOptions = new()
|
23
24
|
{
|
@@ -25,8 +26,9 @@ public partial class DiscoveryWorker : IDiscoveryWorker
|
|
25
26
|
Converters = { new JsonStringEnumConverter() },
|
26
27
|
};
|
27
28
|
|
28
|
-
public DiscoveryWorker(ILogger logger)
|
29
|
+
public DiscoveryWorker(ExperimentsManager experimentsManager, ILogger logger)
|
29
30
|
{
|
31
|
+
_experimentsManager = experimentsManager;
|
30
32
|
_logger = logger;
|
31
33
|
}
|
32
34
|
|
@@ -60,7 +62,7 @@ public partial class DiscoveryWorker : IDiscoveryWorker
|
|
60
62
|
|
61
63
|
public async Task<WorkspaceDiscoveryResult> RunAsync(string repoRootPath, string workspacePath)
|
62
64
|
{
|
63
|
-
MSBuildHelper.RegisterMSBuild(
|
65
|
+
MSBuildHelper.RegisterMSBuild(repoRootPath, workspacePath);
|
64
66
|
|
65
67
|
// the `workspacePath` variable is relative to a repository root, so a rooted path actually isn't rooted; the
|
66
68
|
// easy way to deal with this is to just trim the leading "/" if it exists
|
@@ -74,14 +76,13 @@ public partial class DiscoveryWorker : IDiscoveryWorker
|
|
74
76
|
|
75
77
|
DotNetToolsJsonDiscoveryResult? dotNetToolsJsonDiscovery = null;
|
76
78
|
GlobalJsonDiscoveryResult? globalJsonDiscovery = null;
|
77
|
-
DirectoryPackagesPropsDiscoveryResult? directoryPackagesPropsDiscovery = null;
|
78
79
|
|
79
80
|
ImmutableArray<ProjectDiscoveryResult> projectResults = [];
|
80
81
|
WorkspaceDiscoveryResult result;
|
81
82
|
|
82
83
|
if (Directory.Exists(workspacePath))
|
83
84
|
{
|
84
|
-
_logger.
|
85
|
+
_logger.Info($"Discovering build files in workspace [{workspacePath}].");
|
85
86
|
|
86
87
|
dotNetToolsJsonDiscovery = DotNetToolsJsonDiscovery.Discover(repoRootPath, workspacePath, _logger);
|
87
88
|
globalJsonDiscovery = GlobalJsonDiscovery.Discover(repoRootPath, workspacePath, _logger);
|
@@ -93,17 +94,10 @@ public partial class DiscoveryWorker : IDiscoveryWorker
|
|
93
94
|
|
94
95
|
// this next line should throw or something
|
95
96
|
projectResults = await RunForDirectoryAsnyc(repoRootPath, workspacePath);
|
96
|
-
|
97
|
-
directoryPackagesPropsDiscovery = DirectoryPackagesPropsDiscovery.Discover(repoRootPath, workspacePath, projectResults, _logger);
|
98
|
-
|
99
|
-
if (directoryPackagesPropsDiscovery is not null)
|
100
|
-
{
|
101
|
-
projectResults = projectResults.Remove(projectResults.First(p => p.FilePath.Equals(directoryPackagesPropsDiscovery.FilePath, StringComparison.OrdinalIgnoreCase)));
|
102
|
-
}
|
103
97
|
}
|
104
98
|
else
|
105
99
|
{
|
106
|
-
_logger.
|
100
|
+
_logger.Info($"Workspace path [{workspacePath}] does not exist.");
|
107
101
|
}
|
108
102
|
|
109
103
|
result = new WorkspaceDiscoveryResult
|
@@ -111,11 +105,10 @@ public partial class DiscoveryWorker : IDiscoveryWorker
|
|
111
105
|
Path = initialWorkspacePath,
|
112
106
|
DotNetToolsJson = dotNetToolsJsonDiscovery,
|
113
107
|
GlobalJson = globalJsonDiscovery,
|
114
|
-
DirectoryPackagesProps = directoryPackagesPropsDiscovery,
|
115
108
|
Projects = projectResults.OrderBy(p => p.FilePath).ToImmutableArray(),
|
116
109
|
};
|
117
110
|
|
118
|
-
_logger.
|
111
|
+
_logger.Info("Discovery complete.");
|
119
112
|
_processedProjectPaths.Clear();
|
120
113
|
|
121
114
|
return result;
|
@@ -142,19 +135,19 @@ public partial class DiscoveryWorker : IDiscoveryWorker
|
|
142
135
|
|
143
136
|
_restoredMSBuildSdks.AddRange(keys);
|
144
137
|
|
145
|
-
_logger.
|
138
|
+
_logger.Info($" Restoring MSBuild SDKs: {string.Join(", ", keys)}");
|
146
139
|
|
147
140
|
return await NuGetHelper.DownloadNuGetPackagesAsync(repoRootPath, workspacePath, msbuildSdks, logger);
|
148
141
|
}
|
149
142
|
|
150
143
|
private async Task<ImmutableArray<ProjectDiscoveryResult>> RunForDirectoryAsnyc(string repoRootPath, string workspacePath)
|
151
144
|
{
|
152
|
-
_logger.
|
145
|
+
_logger.Info($" Discovering projects beneath [{Path.GetRelativePath(repoRootPath, workspacePath)}].");
|
153
146
|
var entryPoints = FindEntryPoints(workspacePath);
|
154
147
|
var projects = ExpandEntryPointsIntoProjects(entryPoints);
|
155
148
|
if (projects.IsEmpty)
|
156
149
|
{
|
157
|
-
_logger.
|
150
|
+
_logger.Info(" No project files found.");
|
158
151
|
return [];
|
159
152
|
}
|
160
153
|
|
@@ -271,62 +264,80 @@ public partial class DiscoveryWorker : IDiscoveryWorker
|
|
271
264
|
|
272
265
|
private async Task<ImmutableArray<ProjectDiscoveryResult>> RunForProjectPathsAsync(string repoRootPath, string workspacePath, IEnumerable<string> projectPaths)
|
273
266
|
{
|
274
|
-
var results = new Dictionary<string, ProjectDiscoveryResult>(StringComparer.
|
267
|
+
var results = new Dictionary<string, ProjectDiscoveryResult>(StringComparer.Ordinal);
|
275
268
|
foreach (var projectPath in projectPaths)
|
276
269
|
{
|
277
270
|
// If there is some MSBuild logic that needs to run to fully resolve the path skip the project
|
278
271
|
// Ensure file existence is checked case-insensitively
|
279
|
-
var
|
280
|
-
if (actualProjectPath == null)
|
281
|
-
{
|
282
|
-
continue;
|
283
|
-
}
|
272
|
+
var actualProjectPaths = PathHelper.ResolveCaseInsensitivePathsInsideRepoRoot(projectPath, repoRootPath);
|
284
273
|
|
285
|
-
if (
|
274
|
+
if (actualProjectPaths == null)
|
286
275
|
{
|
287
276
|
continue;
|
288
277
|
}
|
289
|
-
_processedProjectPaths.Add(actualProjectPath);
|
290
278
|
|
291
|
-
var
|
292
|
-
var packagesConfigDependencies = PackagesConfigDiscovery.Discover(workspacePath, projectPath, _logger)
|
293
|
-
?.Dependencies;
|
294
|
-
|
295
|
-
var projectResults = await SdkProjectDiscovery.DiscoverAsync(repoRootPath, workspacePath, actualProjectPath, _logger);
|
296
|
-
|
297
|
-
// Determine if there were unrestored MSBuildSdks
|
298
|
-
var msbuildSdks = projectResults.SelectMany(p => p.Dependencies.Where(d => d.Type == DependencyType.MSBuildSdk)).ToImmutableArray();
|
299
|
-
if (msbuildSdks.Length > 0)
|
279
|
+
foreach (var actualProjectPath in actualProjectPaths)
|
300
280
|
{
|
301
|
-
|
302
|
-
if (await TryRestoreMSBuildSdksAsync(repoRootPath, workspacePath, msbuildSdks, _logger))
|
281
|
+
if (_processedProjectPaths.Contains(actualProjectPath))
|
303
282
|
{
|
304
|
-
|
283
|
+
continue;
|
305
284
|
}
|
306
|
-
}
|
307
285
|
|
308
|
-
|
309
|
-
|
310
|
-
|
286
|
+
_processedProjectPaths.Add(actualProjectPath);
|
287
|
+
|
288
|
+
var relativeProjectPath = Path.GetRelativePath(workspacePath, actualProjectPath).NormalizePathToUnix();
|
289
|
+
var packagesConfigResult = await PackagesConfigDiscovery.Discover(repoRootPath, workspacePath, actualProjectPath, _logger);
|
290
|
+
var projectResults = await SdkProjectDiscovery.DiscoverAsync(repoRootPath, workspacePath, actualProjectPath, _experimentsManager, _logger);
|
291
|
+
|
292
|
+
// Determine if there were unrestored MSBuildSdks
|
293
|
+
var msbuildSdks = projectResults.SelectMany(p => p.Dependencies.Where(d => d.Type == DependencyType.MSBuildSdk)).ToImmutableArray();
|
294
|
+
if (msbuildSdks.Length > 0)
|
311
295
|
{
|
312
|
-
|
296
|
+
// If new SDKs were restored, then we need to rerun SdkProjectDiscovery.
|
297
|
+
if (await TryRestoreMSBuildSdksAsync(repoRootPath, workspacePath, msbuildSdks, _logger))
|
298
|
+
{
|
299
|
+
projectResults = await SdkProjectDiscovery.DiscoverAsync(repoRootPath, workspacePath, actualProjectPath, _experimentsManager, _logger);
|
300
|
+
}
|
313
301
|
}
|
314
302
|
|
315
|
-
|
316
|
-
if (projectResult.FilePath == relativeProjectPath && packagesConfigDependencies is not null)
|
303
|
+
foreach (var projectResult in projectResults)
|
317
304
|
{
|
318
|
-
|
319
|
-
|
320
|
-
|
305
|
+
if (results.ContainsKey(projectResult.FilePath))
|
306
|
+
{
|
307
|
+
continue;
|
308
|
+
}
|
321
309
|
|
322
|
-
|
310
|
+
// If we had packages.config dependencies, merge them with the project dependencies
|
311
|
+
if (projectResult.FilePath == relativeProjectPath && packagesConfigResult is not null)
|
323
312
|
{
|
324
|
-
|
325
|
-
|
313
|
+
var packagesConfigDependencies = packagesConfigResult.Dependencies
|
314
|
+
.Select(d => d with { TargetFrameworks = projectResult.TargetFrameworks })
|
315
|
+
.ToImmutableArray();
|
316
|
+
|
317
|
+
results[projectResult.FilePath] = projectResult with
|
318
|
+
{
|
319
|
+
Dependencies = [.. projectResult.Dependencies, .. packagesConfigDependencies],
|
320
|
+
};
|
321
|
+
}
|
322
|
+
else
|
323
|
+
{
|
324
|
+
results[projectResult.FilePath] = projectResult;
|
325
|
+
}
|
326
326
|
}
|
327
|
-
|
327
|
+
|
328
|
+
if (!results.ContainsKey(relativeProjectPath) &&
|
329
|
+
packagesConfigResult is not null &&
|
330
|
+
packagesConfigResult.Dependencies.Length > 0)
|
328
331
|
{
|
329
|
-
|
332
|
+
// project contained only packages.config dependencies
|
333
|
+
results[relativeProjectPath] = new ProjectDiscoveryResult()
|
334
|
+
{
|
335
|
+
FilePath = relativeProjectPath,
|
336
|
+
Dependencies = packagesConfigResult.Dependencies,
|
337
|
+
TargetFrameworks = packagesConfigResult.TargetFrameworks,
|
338
|
+
ImportedFiles = [], // no imported files resolved for packages.config scenarios
|
339
|
+
AdditionalFiles = packagesConfigResult.AdditionalFiles,
|
340
|
+
};
|
330
341
|
}
|
331
342
|
}
|
332
343
|
}
|
@@ -8,13 +8,13 @@ internal static class DotNetToolsJsonDiscovery
|
|
8
8
|
{
|
9
9
|
if (!MSBuildHelper.TryGetDotNetToolsJsonPath(repoRootPath, workspacePath, out var dotnetToolsJsonPath))
|
10
10
|
{
|
11
|
-
logger.
|
11
|
+
logger.Info(" No dotnet-tools.json file found.");
|
12
12
|
return null;
|
13
13
|
}
|
14
14
|
|
15
15
|
var dotnetToolsJsonFile = DotNetToolsJsonBuildFile.Open(workspacePath, dotnetToolsJsonPath, logger);
|
16
16
|
|
17
|
-
logger.
|
17
|
+
logger.Info($" Discovered [{dotnetToolsJsonFile.RelativePath}] file.");
|
18
18
|
|
19
19
|
var dependencies = BuildFile.GetDependencies(dotnetToolsJsonFile)
|
20
20
|
.OrderBy(d => d.Name)
|
@@ -8,13 +8,13 @@ internal static class GlobalJsonDiscovery
|
|
8
8
|
{
|
9
9
|
if (!MSBuildHelper.TryGetGlobalJsonPath(repoRootPath, workspacePath, out var globalJsonPath))
|
10
10
|
{
|
11
|
-
logger.
|
11
|
+
logger.Info(" No global.json file found.");
|
12
12
|
return null;
|
13
13
|
}
|
14
14
|
|
15
15
|
var globalJsonFile = GlobalJsonBuildFile.Open(workspacePath, globalJsonPath, logger);
|
16
16
|
|
17
|
-
logger.
|
17
|
+
logger.Info($" Discovered [{globalJsonFile.RelativePath}] file.");
|
18
18
|
|
19
19
|
var dependencies = BuildFile.GetDependencies(globalJsonFile)
|
20
20
|
.OrderBy(d => d.Name)
|
@@ -1,29 +1,41 @@
|
|
1
1
|
using System.Collections.Immutable;
|
2
2
|
|
3
|
+
using NuGetUpdater.Core.Utilities;
|
4
|
+
|
3
5
|
namespace NuGetUpdater.Core.Discover;
|
4
6
|
|
5
7
|
internal static class PackagesConfigDiscovery
|
6
8
|
{
|
7
|
-
public static PackagesConfigDiscoveryResult
|
9
|
+
public static async Task<PackagesConfigDiscoveryResult?> Discover(string repoRootPath, string workspacePath, string projectPath, ILogger logger)
|
8
10
|
{
|
9
|
-
|
11
|
+
var projectDirectory = Path.GetDirectoryName(projectPath)!;
|
12
|
+
var additionalFiles = ProjectHelper.GetAllAdditionalFilesFromProject(projectPath, ProjectHelper.PathFormat.Full);
|
13
|
+
var packagesConfigPath = additionalFiles.FirstOrDefault(p => Path.GetFileName(p).Equals(ProjectHelper.PackagesConfigFileName, StringComparison.Ordinal));
|
14
|
+
|
15
|
+
if (packagesConfigPath is null)
|
10
16
|
{
|
11
|
-
logger.
|
17
|
+
logger.Info(" No packages.config file found.");
|
12
18
|
return null;
|
13
19
|
}
|
14
20
|
|
15
21
|
var packagesConfigFile = PackagesConfigBuildFile.Open(workspacePath, packagesConfigPath);
|
16
22
|
|
17
|
-
logger.
|
23
|
+
logger.Info($" Discovered [{packagesConfigFile.RelativePath}] file.");
|
18
24
|
|
19
25
|
var dependencies = BuildFile.GetDependencies(packagesConfigFile)
|
20
26
|
.OrderBy(d => d.Name)
|
21
27
|
.ToImmutableArray();
|
22
28
|
|
29
|
+
// generate `$(TargetFramework)` via MSBuild
|
30
|
+
var tfms = await MSBuildHelper.GetTargetFrameworkValuesFromProject(repoRootPath, projectPath, logger);
|
31
|
+
|
32
|
+
var additionalFilesRelative = additionalFiles.Select(p => Path.GetRelativePath(projectDirectory, p).NormalizePathToUnix()).ToImmutableArray();
|
23
33
|
return new()
|
24
34
|
{
|
25
35
|
FilePath = packagesConfigFile.RelativePath,
|
26
|
-
Dependencies = dependencies,
|
36
|
+
Dependencies = dependencies.Select(d => d with { TargetFrameworks = tfms }).ToImmutableArray(),
|
37
|
+
TargetFrameworks = tfms,
|
38
|
+
AdditionalFiles = additionalFilesRelative,
|
27
39
|
};
|
28
40
|
}
|
29
41
|
}
|
@@ -6,5 +6,7 @@ public sealed record PackagesConfigDiscoveryResult : IDiscoveryResultWithDepende
|
|
6
6
|
{
|
7
7
|
public required string FilePath { get; init; }
|
8
8
|
public bool IsSuccess { get; init; } = true;
|
9
|
-
public ImmutableArray<Dependency> Dependencies { get; init; }
|
9
|
+
public required ImmutableArray<Dependency> Dependencies { get; init; }
|
10
|
+
public required ImmutableArray<string> TargetFrameworks { get; init; }
|
11
|
+
public required ImmutableArray<string> AdditionalFiles { get; init; }
|
10
12
|
}
|
@@ -1,4 +1,5 @@
|
|
1
1
|
using System.Collections.Immutable;
|
2
|
+
using System.Text.Json.Serialization;
|
2
3
|
|
3
4
|
namespace NuGetUpdater.Core.Discover;
|
4
5
|
|
@@ -10,4 +11,6 @@ public record ProjectDiscoveryResult : IDiscoveryResultWithDependencies
|
|
10
11
|
public ImmutableArray<Property> Properties { get; init; } = [];
|
11
12
|
public ImmutableArray<string> TargetFrameworks { get; init; } = [];
|
12
13
|
public ImmutableArray<string> ReferencedProjectPaths { get; init; } = [];
|
14
|
+
public required ImmutableArray<string> ImportedFiles { get; init; }
|
15
|
+
public required ImmutableArray<string> AdditionalFiles { get; init; }
|
13
16
|
}
|