dependabot-nuget 0.288.0 → 0.289.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/helpers/lib/NuGetUpdater/Directory.Packages.props +19 -17
  3. data/helpers/lib/NuGetUpdater/NuGetProjects/NuGet.Packaging/NuGet.Packaging.csproj +0 -1
  4. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Analyze.cs +3 -1
  5. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Discover.cs +23 -3
  6. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/AnalyzeWorker.cs +30 -15
  7. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/CompatabilityChecker.cs +1 -1
  8. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/RequirementArrayConverter.cs +39 -0
  9. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/VersionFinder.cs +1 -1
  10. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Clone/ShellGitCommandHandler.cs +1 -1
  11. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DiscoveryWorker.cs +60 -66
  12. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DotNetToolsJsonDiscovery.cs +2 -2
  13. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/GlobalJsonDiscovery.cs +2 -2
  14. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/PackagesConfigDiscovery.cs +11 -3
  15. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/PackagesConfigDiscoveryResult.cs +1 -0
  16. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/ProjectDiscoveryResult.cs +2 -4
  17. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/SdkProjectDiscovery.cs +54 -11
  18. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/WorkspaceDiscoveryResult.cs +0 -1
  19. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/ExperimentsManager.cs +1 -2
  20. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/JsonBuildFile.cs +1 -1
  21. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/FrameworkChecker/CompatabilityChecker.cs +2 -2
  22. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/RunWorker.cs +43 -54
  23. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/BindingRedirectManager.cs +13 -43
  24. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/DotNetToolsJsonUpdater.cs +4 -4
  25. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/GlobalJsonUpdater.cs +5 -5
  26. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/LockFileUpdater.cs +2 -10
  27. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/PackageReferenceUpdater.cs +38 -33
  28. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/PackagesConfigUpdater.cs +12 -11
  29. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/UpdaterWorker.cs +16 -12
  30. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/ConsoleLogger.cs +1 -1
  31. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/DependencyConflictResolver.cs +19 -19
  32. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/ILogger.cs +11 -1
  33. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/MSBuildHelper.cs +18 -17
  34. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/NuGetHelper.cs +1 -17
  35. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/PathHelper.cs +17 -9
  36. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/ProjectHelper.cs +96 -0
  37. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Analyze/AnalyzeWorkerTests.cs +87 -5
  38. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTestBase.cs +2 -5
  39. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.PackagesConfig.cs +16 -0
  40. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.Proj.cs +6 -0
  41. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.Project.cs +147 -36
  42. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.cs +184 -48
  43. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/ExpectedDiscoveryResults.cs +5 -5
  44. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/SdkProjectDiscoveryTests.cs +32 -10
  45. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/RunWorkerTests.cs +400 -76
  46. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/SerializationTests.cs +2 -2
  47. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/UpdatedDependencyListTests.cs +60 -2
  48. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/TestLogger.cs +1 -1
  49. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/BindingRedirectsTests.cs +1 -1
  50. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTestBase.cs +4 -2
  51. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackageReference.cs +40 -0
  52. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackagesConfig.cs +1 -1
  53. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/AssertEx.cs +1 -1
  54. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/LinuxOnlyAttribute.cs +12 -0
  55. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/MSBuildHelperTests.cs +8 -5
  56. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/PathHelperTests.cs +47 -2
  57. data/lib/dependabot/nuget/analysis/analysis_json_reader.rb +3 -1
  58. data/lib/dependabot/nuget/file_fetcher.rb +12 -393
  59. data/lib/dependabot/nuget/file_parser.rb +23 -60
  60. data/lib/dependabot/nuget/file_updater.rb +21 -16
  61. data/lib/dependabot/nuget/native_discovery/native_dependency_file_discovery.rb +2 -9
  62. data/lib/dependabot/nuget/native_discovery/native_discovery_json_reader.rb +183 -77
  63. data/lib/dependabot/nuget/native_discovery/native_project_discovery.rb +25 -3
  64. data/lib/dependabot/nuget/native_discovery/native_workspace_discovery.rb +1 -8
  65. data/lib/dependabot/nuget/native_update_checker/native_update_checker.rb +17 -4
  66. metadata +8 -9
  67. data/helpers/lib/NuGetUpdater/NuGetProjects/Directory.Packages.props +0 -29
  68. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/RequirementConverter.cs +0 -17
  69. data/lib/dependabot/nuget/file_fetcher/import_paths_finder.rb +0 -73
  70. data/lib/dependabot/nuget/file_fetcher/sln_project_paths_finder.rb +0 -60
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 970779cacdfb8250a46cf1c24ac9fcda325b69b1502c3f0e99b9f1bf80a1add8
4
- data.tar.gz: a8c7a1b0aba00354ffdb35a8903e912d60ce00e73521f53b76b5f20458194e2f
3
+ metadata.gz: 36551f131fff2d82f525e8eb3bd17f26da2d435f4c44484f2b91e0253f041e8f
4
+ data.tar.gz: c97b1b5899bfac76abd674bf58f8853b7790b5e90d74089f2f663dd12f82fd89
5
5
  SHA512:
6
- metadata.gz: 0ae55b0bfbfa8874ef9b2f9a6864587b13d107e9702319397161dbd70c9df97f638b9e906807966f3a0ca2214fce5760c1b4c58eb5b481c68171a270fadbbded
7
- data.tar.gz: bea5ba0649370308fa5a1a6c8d2211708ebdf99d33da6461d38c3a4a10e095b87be83e8ae39b4050fa7ce40ad096fdb349c7bc715971c7e0971ba5eb1f68265d
6
+ metadata.gz: '09e24d02174892b6d10f70bd7e26a200ff0f5d352ba3a69d826598a891d52990c3fd1e839088e4d797df0af6edb53fdb9f3ef9205352c2641cc818b3d603fb97'
7
+ data.tar.gz: 3d9b2b81fee8ff8791796f9d7453f82cdd72a79d2ba3a103303475378fd387d9fb6caedb57688b322dffdb019172ca03910ae6256f79c392d99a233f110e585e
@@ -5,36 +5,38 @@
5
5
  </PropertyGroup>
6
6
 
7
7
  <PropertyGroup>
8
- <MSBuildPackageVersion>17.5.0</MSBuildPackageVersion>
8
+ <MSBuildPackageVersion>17.12.6</MSBuildPackageVersion>
9
9
  </PropertyGroup>
10
10
 
11
11
  <ItemGroup>
12
- <PackageVersion Include="DiffPlex" Version="1.7.1" />
13
-
12
+ <PackageVersion Include="DiffPlex" Version="1.7.2" />
14
13
  <PackageVersion Include="GuiLabs.Language.Xml" Version="1.2.93" />
15
-
14
+ <PackageVersion Include="Microsoft.Build.Locator" Version="1.7.8" />
16
15
  <PackageVersion Include="Microsoft.Build" Version="$(MSBuildPackageVersion)" />
17
16
  <PackageVersion Include="Microsoft.Build.Framework" Version="$(MSBuildPackageVersion)" />
18
- <PackageVersion Include="Microsoft.Build.Locator" Version="1.7.8" />
17
+ <PackageVersion Include="Microsoft.Build.Tasks.Core" Version="$(MSBuildPackageVersion)" />
19
18
  <PackageVersion Include="Microsoft.Build.Utilities.Core" Version="$(MSBuildPackageVersion)" />
20
-
21
- <PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.9.2" />
22
-
23
- <PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
24
-
19
+ <PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.11.0" />
20
+ <PackageVersion Include="Microsoft.CSharp" Version="4.7.0" />
21
+ <PackageVersion Include="Microsoft.Extensions.FileProviders.Abstractions" Version="9.0.0" />
22
+ <PackageVersion Include="Microsoft.Extensions.FileSystemGlobbing" Version="9.0.0" />
23
+ <PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
24
+ <PackageVersion Include="Microsoft.VisualStudio.Setup.Configuration.Interop" Version="3.12.2149" />
25
+ <PackageVersion Include="Microsoft.Web.Xdt" Version="3.1.0" />
25
26
  <PackageVersion Include="MSBuild.StructuredLogger" Version="2.2.386" />
26
-
27
- <PackageVersion Include="NuGet.Core" Version="2.14.0-rtm-832" Aliases="CoreV2" />
28
-
27
+ <PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
28
+ <PackageVersion Include="NuGet.Core" Version="2.14.0" Aliases="CoreV2" />
29
29
  <PackageVersion Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
30
+ <PackageVersion Include="System.ComponentModel.Composition" Version="9.0.0" />
30
31
  <PackageVersion Include="System.Net.Http" Version="4.3.4" />
31
32
  <PackageVersion Include="System.Formats.Asn1" Version="8.0.1" />
32
- <PackageVersion Include="System.Security.Cryptography.Pkcs" Version="8.0.0" />
33
+ <PackageVersion Include="System.Security.Cryptography.Pkcs" Version="9.0.0" />
34
+ <PackageVersion Include="System.Security.Cryptography.ProtectedData" Version="9.0.0" />
33
35
  <PackageVersion Include="System.Text.Json" Version="8.0.4" />
34
36
  <PackageVersion Include="System.Text.RegularExpressions" Version="4.3.1" />
35
-
36
- <PackageVersion Include="xunit" Version="2.4.2" />
37
- <PackageVersion Include="xunit.runner.visualstudio" Version="2.4.5" />
37
+ <PackageVersion Include="System.Threading.Tasks.Dataflow" Version="9.0.0" />
38
+ <PackageVersion Include="xunit" Version="2.9.2" />
39
+ <PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />
38
40
  </ItemGroup>
39
41
 
40
42
  </Project>
@@ -14,7 +14,6 @@
14
14
  <ItemGroup>
15
15
  <PackageReference Include="Newtonsoft.Json" />
16
16
  <PackageReference Include="System.Security.Cryptography.Pkcs" />
17
- <PackageReference Include="System.Security.Cryptography.Cng" />
18
17
  </ItemGroup>
19
18
 
20
19
  <ItemGroup>
@@ -94,7 +94,9 @@ public partial class EntryPointTests
94
94
  "TargetFrameworks": [
95
95
  "net8.0"
96
96
  ],
97
- "ReferencedProjectPaths": []
97
+ "ReferencedProjectPaths": [],
98
+ "ImportedFiles": [],
99
+ "AdditionalFiles": []
98
100
  }
99
101
  ],
100
102
  "DirectoryPackagesProps": null,
@@ -66,6 +66,9 @@ public partial class EntryPointTests
66
66
  Properties = [
67
67
  new("TargetFramework", "net8.0", "path/to/some directory with spaces/project.csproj"),
68
68
  ],
69
+ ReferencedProjectPaths = [],
70
+ ImportedFiles = [],
71
+ AdditionalFiles = [],
69
72
  }
70
73
  ]
71
74
  }
@@ -156,6 +159,11 @@ public partial class EntryPointTests
156
159
  new("Some.Package", "7.0.1", DependencyType.PackagesConfig, TargetFrameworks: ["net45"]),
157
160
  ],
158
161
  Properties = [],
162
+ ReferencedProjectPaths = [],
163
+ ImportedFiles = [],
164
+ AdditionalFiles = [
165
+ "packages.config"
166
+ ],
159
167
  }
160
168
  ]
161
169
  }
@@ -223,6 +231,11 @@ public partial class EntryPointTests
223
231
  new("Some.Package", "7.0.1", DependencyType.PackagesConfig, TargetFrameworks: ["net45"])
224
232
  ],
225
233
  Properties = [],
234
+ ReferencedProjectPaths = [],
235
+ ImportedFiles = [],
236
+ AdditionalFiles = [
237
+ "packages.config"
238
+ ],
226
239
  }
227
240
  ]
228
241
  }
@@ -291,6 +304,11 @@ public partial class EntryPointTests
291
304
  new("Some.Package", "7.0.1", DependencyType.PackagesConfig, TargetFrameworks: ["net45"])
292
305
  ],
293
306
  Properties = [],
307
+ ReferencedProjectPaths = [],
308
+ ImportedFiles = [],
309
+ AdditionalFiles = [
310
+ "packages.config"
311
+ ],
294
312
  }
295
313
  ]
296
314
  }
@@ -359,11 +377,13 @@ public partial class EntryPointTests
359
377
  new("ManagePackageVersionsCentrally", "false", "path/to/my.csproj"),
360
378
  new("TargetFramework", "net8.0", "path/to/my.csproj"),
361
379
  ],
380
+ ReferencedProjectPaths = [],
381
+ ImportedFiles = [
382
+ "../Directory.Build.props"
383
+ ],
384
+ AdditionalFiles = [],
362
385
  }
363
386
  ],
364
- ImportedFiles = [
365
- "Directory.Build.props"
366
- ]
367
387
  }
368
388
  );
369
389
  }
@@ -21,7 +21,7 @@ public partial class AnalyzeWorker : IAnalyzeWorker
21
21
  internal static readonly JsonSerializerOptions SerializerOptions = new()
22
22
  {
23
23
  WriteIndented = true,
24
- Converters = { new JsonStringEnumConverter(), new RequirementConverter() },
24
+ Converters = { new JsonStringEnumConverter(), new RequirementArrayConverter() },
25
25
  };
26
26
 
27
27
  public AnalyzeWorker(ILogger logger)
@@ -32,15 +32,15 @@ public partial class AnalyzeWorker : IAnalyzeWorker
32
32
  public async Task RunAsync(string repoRoot, string discoveryPath, string dependencyPath, string analysisDirectory)
33
33
  {
34
34
  var analysisResult = await RunWithErrorHandlingAsync(repoRoot, discoveryPath, dependencyPath);
35
- var dependencyInfo = await DeserializeJsonFileAsync<DependencyInfo>(dependencyPath, nameof(DependencyInfo));
35
+ var dependencyInfo = await DeserializeDependencyInfoFileAsync(dependencyPath);
36
36
  await WriteResultsAsync(analysisDirectory, dependencyInfo.Name, analysisResult, _logger);
37
37
  }
38
38
 
39
39
  internal async Task<AnalysisResult> RunWithErrorHandlingAsync(string repoRoot, string discoveryPath, string dependencyPath)
40
40
  {
41
41
  AnalysisResult analysisResult;
42
- var discovery = await DeserializeJsonFileAsync<WorkspaceDiscoveryResult>(discoveryPath, nameof(WorkspaceDiscoveryResult));
43
- var dependencyInfo = await DeserializeJsonFileAsync<DependencyInfo>(dependencyPath, nameof(DependencyInfo));
42
+ var discovery = await DeserializeWorkspaceDiscoveryResultFileAsync(discoveryPath);
43
+ var dependencyInfo = await DeserializeDependencyInfoFileAsync(dependencyPath);
44
44
 
45
45
  try
46
46
  {
@@ -68,7 +68,7 @@ public partial class AnalyzeWorker : IAnalyzeWorker
68
68
  {
69
69
  var startingDirectory = PathHelper.JoinPath(repoRoot, discovery.Path);
70
70
 
71
- _logger.Log($"Starting analysis of {dependencyInfo.Name}...");
71
+ _logger.Info($"Starting analysis of {dependencyInfo.Name}...");
72
72
 
73
73
  // We need to find all projects which have the given dependency. Even in cases that they
74
74
  // have it transitively may require that peer dependencies be updated in the project.
@@ -97,7 +97,7 @@ public partial class AnalyzeWorker : IAnalyzeWorker
97
97
  AnalysisResult analysisResult;
98
98
  if (isUpdateNecessary)
99
99
  {
100
- _logger.Log($" Determining multi-dependency property.");
100
+ _logger.Info($" Determining multi-dependency property.");
101
101
  var multiDependencies = DetermineMultiDependencyDetails(
102
102
  discovery,
103
103
  dependencyInfo.Name,
@@ -117,7 +117,7 @@ public partial class AnalyzeWorker : IAnalyzeWorker
117
117
  .ToImmutableArray()
118
118
  : projectFrameworks;
119
119
 
120
- _logger.Log($" Finding updated version.");
120
+ _logger.Info($" Finding updated version.");
121
121
  updatedVersion = await FindUpdatedVersionAsync(
122
122
  startingDirectory,
123
123
  dependencyInfo,
@@ -127,7 +127,7 @@ public partial class AnalyzeWorker : IAnalyzeWorker
127
127
  _logger,
128
128
  CancellationToken.None);
129
129
 
130
- _logger.Log($" Finding updated peer dependencies.");
130
+ _logger.Info($" Finding updated peer dependencies.");
131
131
  if (updatedVersion is null)
132
132
  {
133
133
  updatedDependencies = [];
@@ -173,7 +173,7 @@ public partial class AnalyzeWorker : IAnalyzeWorker
173
173
  UpdatedDependencies = updatedDependencies,
174
174
  };
175
175
 
176
- _logger.Log($"Analysis complete.");
176
+ _logger.Info($"Analysis complete.");
177
177
  return analysisResult;
178
178
  }
179
179
 
@@ -197,13 +197,28 @@ public partial class AnalyzeWorker : IAnalyzeWorker
197
197
  !d.IsTransitive));
198
198
  }
199
199
 
200
- internal static async Task<T> DeserializeJsonFileAsync<T>(string path, string fileType)
200
+ private static Task<WorkspaceDiscoveryResult> DeserializeWorkspaceDiscoveryResultFileAsync(string path)
201
201
  {
202
- var json = File.Exists(path)
203
- ? await File.ReadAllTextAsync(path)
204
- : throw new FileNotFoundException($"{fileType} file not found.", path);
202
+ return DeserializeJsonFileAsync(path, nameof(WorkspaceDiscoveryResult), json => JsonSerializer.Deserialize<WorkspaceDiscoveryResult>(json, SerializerOptions));
203
+ }
204
+
205
+ private static Task<DependencyInfo> DeserializeDependencyInfoFileAsync(string path)
206
+ {
207
+ return DeserializeJsonFileAsync(path, nameof(DependencyInfo), DeserializeDependencyInfo);
208
+ }
209
+
210
+ internal static DependencyInfo? DeserializeDependencyInfo(string content)
211
+ {
212
+ return JsonSerializer.Deserialize<DependencyInfo>(content, SerializerOptions);
213
+ }
214
+
215
+ private static async Task<T> DeserializeJsonFileAsync<T>(string filePath, string fileType, Func<string, T?> deserializer)
216
+ {
217
+ var json = File.Exists(filePath)
218
+ ? await File.ReadAllTextAsync(filePath)
219
+ : throw new FileNotFoundException($"{fileType} file not found.", filePath);
205
220
 
206
- return JsonSerializer.Deserialize<T>(json, SerializerOptions)
221
+ return deserializer(json)
207
222
  ?? throw new InvalidOperationException($"{fileType} file is empty.");
208
223
  }
209
224
 
@@ -468,7 +483,7 @@ public partial class AnalyzeWorker : IAnalyzeWorker
468
483
 
469
484
  var resultPath = Path.Combine(analysisDirectory, $"{dependencyName}.json");
470
485
 
471
- logger.Log($" Writing analysis result to [{resultPath}].");
486
+ logger.Info($" Writing analysis result to [{resultPath}].");
472
487
 
473
488
  var resultJson = JsonSerializer.Serialize(result, SerializerOptions);
474
489
  await File.WriteAllTextAsync(path: resultPath, resultJson);
@@ -68,7 +68,7 @@ internal static class CompatibilityChecker
68
68
  var incompatibleFrameworks = projectFrameworks.Where(f => !compatibleFrameworks.Contains(f)).ToArray();
69
69
  if (incompatibleFrameworks.Length > 0)
70
70
  {
71
- logger.Log($"The package {package} is not compatible. Incompatible project frameworks: {string.Join(", ", incompatibleFrameworks.Select(f => f.GetShortFolderName()))}");
71
+ logger.Info($"The package {package} is not compatible. Incompatible project frameworks: {string.Join(", ", incompatibleFrameworks.Select(f => f.GetShortFolderName()))}");
72
72
  return false;
73
73
  }
74
74
 
@@ -0,0 +1,39 @@
1
+ using System.Collections.Immutable;
2
+ using System.Text.Json;
3
+ using System.Text.Json.Serialization;
4
+
5
+ namespace NuGetUpdater.Core.Analyze;
6
+
7
+ public class RequirementArrayConverter : JsonConverter<ImmutableArray<Requirement>>
8
+ {
9
+ public override ImmutableArray<Requirement> Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
10
+ {
11
+ var requirements = new List<Requirement>();
12
+ var requirementStrings = JsonSerializer.Deserialize<string[]>(ref reader, options) ?? [];
13
+ foreach (var requirementString in requirementStrings)
14
+ {
15
+ try
16
+ {
17
+ var requirement = Requirement.Parse(requirementString);
18
+ requirements.Add(requirement);
19
+ }
20
+ catch (ArgumentException)
21
+ {
22
+ // couldn't parse, nothing to do
23
+ }
24
+ }
25
+
26
+ return requirements.ToImmutableArray();
27
+ }
28
+
29
+ public override void Write(Utf8JsonWriter writer, ImmutableArray<Requirement> value, JsonSerializerOptions options)
30
+ {
31
+ writer.WriteStartArray();
32
+ foreach (var requirement in value)
33
+ {
34
+ writer.WriteStringValue(requirement.ToString());
35
+ }
36
+
37
+ writer.WriteEndArray();
38
+ }
39
+ }
@@ -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.Log($"Failed to get MetadataResource for [{source.Source}]");
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.Log($"Running command: git {string.Join(" ", args)}{(workingDirectory is null ? "" : $" in directory {workingDirectory}")}");
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
  }
@@ -18,7 +18,7 @@ public partial class DiscoveryWorker : IDiscoveryWorker
18
18
 
19
19
  private readonly ExperimentsManager _experimentsManager;
20
20
  private readonly ILogger _logger;
21
- private readonly HashSet<string> _processedProjectPaths = new(StringComparer.OrdinalIgnoreCase); private readonly HashSet<string> _restoredMSBuildSdks = new(StringComparer.OrdinalIgnoreCase);
21
+ private readonly HashSet<string> _processedProjectPaths = new(StringComparer.Ordinal); private readonly HashSet<string> _restoredMSBuildSdks = new(StringComparer.OrdinalIgnoreCase);
22
22
 
23
23
  internal static readonly JsonSerializerOptions SerializerOptions = new()
24
24
  {
@@ -54,7 +54,6 @@ public partial class DiscoveryWorker : IDiscoveryWorker
54
54
  ErrorDetails = "(" + string.Join("|", NuGetContext.GetPackageSourceUrls(PathHelper.JoinPath(repoRootPath, workspacePath))) + ")",
55
55
  Path = workspacePath,
56
56
  Projects = [],
57
- ImportedFiles = [],
58
57
  };
59
58
  }
60
59
 
@@ -83,7 +82,7 @@ public partial class DiscoveryWorker : IDiscoveryWorker
83
82
 
84
83
  if (Directory.Exists(workspacePath))
85
84
  {
86
- _logger.Log($"Discovering build files in workspace [{workspacePath}].");
85
+ _logger.Info($"Discovering build files in workspace [{workspacePath}].");
87
86
 
88
87
  dotNetToolsJsonDiscovery = DotNetToolsJsonDiscovery.Discover(repoRootPath, workspacePath, _logger);
89
88
  globalJsonDiscovery = GlobalJsonDiscovery.Discover(repoRootPath, workspacePath, _logger);
@@ -98,18 +97,7 @@ public partial class DiscoveryWorker : IDiscoveryWorker
98
97
  }
99
98
  else
100
99
  {
101
- _logger.Log($"Workspace path [{workspacePath}] does not exist.");
102
- }
103
-
104
- var importedFiles = new HashSet<string>(PathComparer.Instance);
105
- foreach (var project in projectResults)
106
- {
107
- // imported files are relative to the project and need to be converted to be relative to the repo root
108
- var repoRootRelativeImportedFiles = project.ImportedFiles
109
- .Select(p => Path.Join(Path.GetDirectoryName(project.FilePath) ?? "", p))
110
- .Select(p => p.NormalizePathToUnix().NormalizeUnixPathParts())
111
- .ToArray();
112
- importedFiles.AddRange(repoRootRelativeImportedFiles);
100
+ _logger.Info($"Workspace path [{workspacePath}] does not exist.");
113
101
  }
114
102
 
115
103
  result = new WorkspaceDiscoveryResult
@@ -118,10 +106,9 @@ public partial class DiscoveryWorker : IDiscoveryWorker
118
106
  DotNetToolsJson = dotNetToolsJsonDiscovery,
119
107
  GlobalJson = globalJsonDiscovery,
120
108
  Projects = projectResults.OrderBy(p => p.FilePath).ToImmutableArray(),
121
- ImportedFiles = importedFiles.ToImmutableArray(),
122
109
  };
123
110
 
124
- _logger.Log("Discovery complete.");
111
+ _logger.Info("Discovery complete.");
125
112
  _processedProjectPaths.Clear();
126
113
 
127
114
  return result;
@@ -148,19 +135,19 @@ public partial class DiscoveryWorker : IDiscoveryWorker
148
135
 
149
136
  _restoredMSBuildSdks.AddRange(keys);
150
137
 
151
- _logger.Log($" Restoring MSBuild SDKs: {string.Join(", ", keys)}");
138
+ _logger.Info($" Restoring MSBuild SDKs: {string.Join(", ", keys)}");
152
139
 
153
140
  return await NuGetHelper.DownloadNuGetPackagesAsync(repoRootPath, workspacePath, msbuildSdks, logger);
154
141
  }
155
142
 
156
143
  private async Task<ImmutableArray<ProjectDiscoveryResult>> RunForDirectoryAsnyc(string repoRootPath, string workspacePath)
157
144
  {
158
- _logger.Log($" Discovering projects beneath [{Path.GetRelativePath(repoRootPath, workspacePath)}].");
145
+ _logger.Info($" Discovering projects beneath [{Path.GetRelativePath(repoRootPath, workspacePath)}].");
159
146
  var entryPoints = FindEntryPoints(workspacePath);
160
147
  var projects = ExpandEntryPointsIntoProjects(entryPoints);
161
148
  if (projects.IsEmpty)
162
149
  {
163
- _logger.Log(" No project files found.");
150
+ _logger.Info(" No project files found.");
164
151
  return [];
165
152
  }
166
153
 
@@ -277,74 +264,81 @@ public partial class DiscoveryWorker : IDiscoveryWorker
277
264
 
278
265
  private async Task<ImmutableArray<ProjectDiscoveryResult>> RunForProjectPathsAsync(string repoRootPath, string workspacePath, IEnumerable<string> projectPaths)
279
266
  {
280
- var results = new Dictionary<string, ProjectDiscoveryResult>(StringComparer.OrdinalIgnoreCase);
267
+ var results = new Dictionary<string, ProjectDiscoveryResult>(StringComparer.Ordinal);
281
268
  foreach (var projectPath in projectPaths)
282
269
  {
283
270
  // If there is some MSBuild logic that needs to run to fully resolve the path skip the project
284
271
  // Ensure file existence is checked case-insensitively
285
- var actualProjectPath = PathHelper.ResolveCaseInsensitivePathInsideRepoRoot(projectPath, repoRootPath);
286
- if (actualProjectPath == null)
287
- {
288
- continue;
289
- }
272
+ var actualProjectPaths = PathHelper.ResolveCaseInsensitivePathsInsideRepoRoot(projectPath, repoRootPath);
290
273
 
291
- if (_processedProjectPaths.Contains(actualProjectPath))
274
+ if (actualProjectPaths == null)
292
275
  {
293
276
  continue;
294
277
  }
295
- _processedProjectPaths.Add(actualProjectPath);
296
278
 
297
- var relativeProjectPath = Path.GetRelativePath(workspacePath, actualProjectPath).NormalizePathToUnix();
298
- var packagesConfigResult = await PackagesConfigDiscovery.Discover(repoRootPath, workspacePath, actualProjectPath, _logger);
299
- var projectResults = await SdkProjectDiscovery.DiscoverAsync(repoRootPath, workspacePath, actualProjectPath, _experimentsManager, _logger);
300
-
301
- // Determine if there were unrestored MSBuildSdks
302
- var msbuildSdks = projectResults.SelectMany(p => p.Dependencies.Where(d => d.Type == DependencyType.MSBuildSdk)).ToImmutableArray();
303
- if (msbuildSdks.Length > 0)
279
+ foreach (var actualProjectPath in actualProjectPaths)
304
280
  {
305
- // If new SDKs were restored, then we need to rerun SdkProjectDiscovery.
306
- if (await TryRestoreMSBuildSdksAsync(repoRootPath, workspacePath, msbuildSdks, _logger))
281
+ if (_processedProjectPaths.Contains(actualProjectPath))
307
282
  {
308
- projectResults = await SdkProjectDiscovery.DiscoverAsync(repoRootPath, workspacePath, actualProjectPath, _experimentsManager, _logger);
283
+ continue;
309
284
  }
310
- }
311
285
 
312
- foreach (var projectResult in projectResults)
313
- {
314
- if (results.ContainsKey(projectResult.FilePath))
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)
315
295
  {
316
- continue;
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
+ }
317
301
  }
318
302
 
319
- // If we had packages.config dependencies, merge them with the project dependencies
320
- if (projectResult.FilePath == relativeProjectPath && packagesConfigResult is not null)
303
+ foreach (var projectResult in projectResults)
321
304
  {
322
- var packagesConfigDependencies = packagesConfigResult.Dependencies
323
- .Select(d => d with { TargetFrameworks = projectResult.TargetFrameworks })
324
- .ToImmutableArray();
305
+ if (results.ContainsKey(projectResult.FilePath))
306
+ {
307
+ continue;
308
+ }
325
309
 
326
- results[projectResult.FilePath] = projectResult with
310
+ // If we had packages.config dependencies, merge them with the project dependencies
311
+ if (projectResult.FilePath == relativeProjectPath && packagesConfigResult is not null)
327
312
  {
328
- Dependencies = [.. projectResult.Dependencies, .. packagesConfigDependencies],
329
- };
330
- }
331
- else
332
- {
333
- results[projectResult.FilePath] = projectResult;
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
+ }
334
326
  }
335
- }
336
327
 
337
- if (!results.ContainsKey(relativeProjectPath) &&
338
- packagesConfigResult is not null &&
339
- packagesConfigResult.Dependencies.Length > 0)
340
- {
341
- // project contained only packages.config dependencies
342
- results[relativeProjectPath] = new ProjectDiscoveryResult()
328
+ if (!results.ContainsKey(relativeProjectPath) &&
329
+ packagesConfigResult is not null &&
330
+ packagesConfigResult.Dependencies.Length > 0)
343
331
  {
344
- FilePath = relativeProjectPath,
345
- Dependencies = packagesConfigResult.Dependencies,
346
- TargetFrameworks = packagesConfigResult.TargetFrameworks,
347
- };
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
+ };
341
+ }
348
342
  }
349
343
  }
350
344
 
@@ -8,13 +8,13 @@ internal static class DotNetToolsJsonDiscovery
8
8
  {
9
9
  if (!MSBuildHelper.TryGetDotNetToolsJsonPath(repoRootPath, workspacePath, out var dotnetToolsJsonPath))
10
10
  {
11
- logger.Log(" No dotnet-tools.json file found.");
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.Log($" Discovered [{dotnetToolsJsonFile.RelativePath}] file.");
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.Log(" No global.json file found.");
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.Log($" Discovered [{globalJsonFile.RelativePath}] file.");
17
+ logger.Info($" Discovered [{globalJsonFile.RelativePath}] file.");
18
18
 
19
19
  var dependencies = BuildFile.GetDependencies(globalJsonFile)
20
20
  .OrderBy(d => d.Name)
@@ -1,20 +1,26 @@
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
9
  public static async Task<PackagesConfigDiscoveryResult?> Discover(string repoRootPath, string workspacePath, string projectPath, ILogger logger)
8
10
  {
9
- if (!NuGetHelper.TryGetPackagesConfigFile(projectPath, out var packagesConfigPath))
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.Log(" No packages.config file found.");
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.Log($" Discovered [{packagesConfigFile.RelativePath}] file.");
23
+ logger.Info($" Discovered [{packagesConfigFile.RelativePath}] file.");
18
24
 
19
25
  var dependencies = BuildFile.GetDependencies(packagesConfigFile)
20
26
  .OrderBy(d => d.Name)
@@ -23,11 +29,13 @@ internal static class PackagesConfigDiscovery
23
29
  // generate `$(TargetFramework)` via MSBuild
24
30
  var tfms = await MSBuildHelper.GetTargetFrameworkValuesFromProject(repoRootPath, projectPath, logger);
25
31
 
32
+ var additionalFilesRelative = additionalFiles.Select(p => Path.GetRelativePath(projectDirectory, p).NormalizePathToUnix()).ToImmutableArray();
26
33
  return new()
27
34
  {
28
35
  FilePath = packagesConfigFile.RelativePath,
29
36
  Dependencies = dependencies.Select(d => d with { TargetFrameworks = tfms }).ToImmutableArray(),
30
37
  TargetFrameworks = tfms,
38
+ AdditionalFiles = additionalFilesRelative,
31
39
  };
32
40
  }
33
41
  }
@@ -8,4 +8,5 @@ public sealed record PackagesConfigDiscoveryResult : IDiscoveryResultWithDepende
8
8
  public bool IsSuccess { get; init; } = true;
9
9
  public required ImmutableArray<Dependency> Dependencies { get; init; }
10
10
  public required ImmutableArray<string> TargetFrameworks { get; init; }
11
+ public required ImmutableArray<string> AdditionalFiles { get; init; }
11
12
  }
@@ -11,8 +11,6 @@ public record ProjectDiscoveryResult : IDiscoveryResultWithDependencies
11
11
  public ImmutableArray<Property> Properties { get; init; } = [];
12
12
  public ImmutableArray<string> TargetFrameworks { get; init; } = [];
13
13
  public ImmutableArray<string> ReferencedProjectPaths { get; init; } = [];
14
-
15
- // this is purely for internal record keeping and should not be serialized
16
- [JsonIgnore]
17
- public ImmutableArray<string> ImportedFiles { get; init; } = [];
14
+ public required ImmutableArray<string> ImportedFiles { get; init; }
15
+ public required ImmutableArray<string> AdditionalFiles { get; init; }
18
16
  }