dependabot-nuget 0.267.0 → 0.270.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 19fd9d2635d3d1f5737870ebe8bcd155fb5e90557c7eec2b6832233bb0573b29
4
- data.tar.gz: d1bd4ff99ae3fd8319a796cf04ba3a859c084cd465013cd5a1c8b106969a8183
3
+ metadata.gz: 690337cc223bbf06e50f9f66fff955f966931bbc4368fe4d5849efb386c4a123
4
+ data.tar.gz: bce0d34b0c79064c99a511b88b8087f5d287ff7fef85aa01bb32b6d3b824a7d4
5
5
  SHA512:
6
- metadata.gz: 4b1c5c0ed9ca379e3c209c21dbc047e7364a9c3f7eda956ebd11a6f0f44b5a3a3e5a7fe9493ccafe82ac98bad132ab2323a56817c2f234c135814282cd229c30
7
- data.tar.gz: c0f297752cb28d6c32df1261ab10199a5f39e17af23f3c3e46ed76aafd59785e79cd43c81e1a164b8fe92b9f7763f50e3d2c4a8d34c9bb59a4976d0e6eb44be4
6
+ metadata.gz: 431e6a7b442ce8a7430882a125ccebe3b77b54dfc68698aa5c6279be0cde427a924c3faafceb0b1414d2e0feff35ad43e29e31aa410b11ea3bf451ac5cbf5288
7
+ data.tar.gz: 805297f077777b6cc7f8fdccbe46a37909b008bd7a09abfc86816ad3cdfda1da837b8fa49f8c4086e5910c27f61bc2179b4b550d84e26cabc378d34201aee4f5
@@ -407,6 +407,7 @@ public partial class EntryPointTests
407
407
  try
408
408
  {
409
409
  await MockNuGetPackagesInDirectory(packages, path);
410
+
410
411
  var args = getArgs(path);
411
412
  var result = await Program.Main(args);
412
413
  if (result != 0)
@@ -255,6 +255,12 @@ public partial class AnalyzeWorker
255
255
  CancellationToken cancellationToken)
256
256
  {
257
257
  var versions = versionResult.GetVersions();
258
+ if (versions.Length == 0)
259
+ {
260
+ // if absolutely nothing was found, then we can't update
261
+ return null;
262
+ }
263
+
258
264
  var orderedVersions = findLowestVersion
259
265
  ? versions.OrderBy(v => v) // If we are fixing a vulnerability, then we want the lowest version that is safe.
260
266
  : versions.OrderByDescending(v => v); // If we are just updating versions, then we want the highest version possible.
@@ -84,24 +84,27 @@ internal static class CompatibilityChecker
84
84
  var reader = new NuspecReader(nuspecStream);
85
85
 
86
86
  var isDevDependency = reader.GetDevelopmentDependency();
87
+ var tfms = new HashSet<NuGetFramework>();
88
+ var dependencyGroups = reader.GetDependencyGroups().ToArray();
87
89
 
88
- var tfms = reader.GetDependencyGroups()
89
- .Select(d => d.TargetFramework)
90
- .ToImmutableArray();
91
- if (tfms.Length == 0)
90
+ foreach (var d in dependencyGroups)
92
91
  {
93
- // If the nuspec doesn't have any dependency groups,
94
- // try to get the TargetFramework from files in the lib folder.
95
92
  var libItems = (await readers.ContentReader.GetLibItemsAsync(cancellationToken)).ToList();
96
- if (libItems.Count == 0)
93
+
94
+ foreach (var item in libItems)
97
95
  {
98
- // If there is no lib folder in this package, then assume it is a dev dependency.
99
- isDevDependency = true;
96
+ tfms.Add(item.TargetFramework);
100
97
  }
101
98
 
102
- tfms = libItems.Select(item => item.TargetFramework)
103
- .Distinct()
104
- .ToImmutableArray();
99
+ if (!d.TargetFramework.IsAny)
100
+ {
101
+ tfms.Add(d.TargetFramework);
102
+ }
103
+ }
104
+
105
+ if (!tfms.Any())
106
+ {
107
+ tfms.Add(NuGetFramework.AnyFramework);
105
108
  }
106
109
 
107
110
  // The interfaces we given are not disposable but the underlying type can be.
@@ -109,7 +112,7 @@ internal static class CompatibilityChecker
109
112
  (readers.CoreReader as IDisposable)?.Dispose();
110
113
  (readers.ContentReader as IDisposable)?.Dispose();
111
114
 
112
- return (isDevDependency, tfms);
115
+ return (isDevDependency, tfms.ToImmutableArray());
113
116
  }
114
117
 
115
118
  internal static PackageReaders ReadPackage(string tempPackagePath)
@@ -116,7 +116,14 @@ public class IndividualRequirement : Requirement
116
116
  : [requirement[..(splitIndex + 1)].Trim(), requirement[(splitIndex + 1)..].Trim()];
117
117
 
118
118
  var op = parts.Length == 1 ? "=" : parts[0];
119
- var version = NuGetVersion.Parse(parts[^1]);
119
+ var versionString = parts[^1];
120
+
121
+ // allow for single character wildcards; may be asterisk (NuGet-style: 1.*) or a single letter (alternate style: 1.x)
122
+ var versionParts = versionString.Split('.');
123
+ var recreatedVersionParts = versionParts.Select(vp => vp.Length == 1 && (vp == "*" || char.IsAsciiLetter(vp[0])) ? "0" : vp).ToArray();
124
+
125
+ var rebuiltVersionString = string.Join(".", recreatedVersionParts);
126
+ var version = NuGetVersion.Parse(rebuiltVersionString);
120
127
 
121
128
  return new IndividualRequirement(op, version);
122
129
  }
@@ -24,6 +24,7 @@ internal static class SdkPackageUpdater
24
24
 
25
25
  // Get the set of all top-level dependencies in the current project
26
26
  var topLevelDependencies = MSBuildHelper.GetTopLevelPackageDependencyInfos(buildFiles).ToArray();
27
+
27
28
  if (!await DoesDependencyRequireUpdateAsync(repoRootPath, projectPath, tfms, topLevelDependencies, dependencyName, newDependencyVersion, logger))
28
29
  {
29
30
  return;
@@ -31,7 +32,7 @@ internal static class SdkPackageUpdater
31
32
 
32
33
  if (isTransitive)
33
34
  {
34
- await UpdateTransitiveDependencyAsnyc(projectPath, dependencyName, newDependencyVersion, buildFiles, logger);
35
+ await UpdateTransitiveDependencyAsync(repoRootPath, projectPath, dependencyName, newDependencyVersion, buildFiles, logger);
35
36
  }
36
37
  else
37
38
  {
@@ -123,7 +124,7 @@ internal static class SdkPackageUpdater
123
124
  return true;
124
125
  }
125
126
 
126
- private static async Task UpdateTransitiveDependencyAsnyc(string projectPath, string dependencyName, string newDependencyVersion, ImmutableArray<ProjectBuildFile> buildFiles, Logger logger)
127
+ private static async Task UpdateTransitiveDependencyAsync(string repoRootPath, string projectPath, string dependencyName, string newDependencyVersion, ImmutableArray<ProjectBuildFile> buildFiles, Logger logger)
127
128
  {
128
129
  var directoryPackagesWithPinning = buildFiles.OfType<ProjectBuildFile>()
129
130
  .FirstOrDefault(bf => IsCpmTransitivePinningEnabled(bf));
@@ -133,7 +134,7 @@ internal static class SdkPackageUpdater
133
134
  }
134
135
  else
135
136
  {
136
- await AddTransitiveDependencyAsync(projectPath, dependencyName, newDependencyVersion, logger);
137
+ await AddTransitiveDependencyAsync(repoRootPath, projectPath, dependencyName, newDependencyVersion, logger);
137
138
  }
138
139
  }
139
140
 
@@ -222,17 +223,21 @@ internal static class SdkPackageUpdater
222
223
  directoryPackages.Update(updatedXml);
223
224
  }
224
225
 
225
- private static async Task AddTransitiveDependencyAsync(string projectPath, string dependencyName, string newDependencyVersion, Logger logger)
226
+ private static async Task AddTransitiveDependencyAsync(string repoRootPath, string projectPath, string dependencyName, string newDependencyVersion, Logger logger)
226
227
  {
227
- logger.Log($" Adding [{dependencyName}/{newDependencyVersion}] as a top-level package reference.");
228
-
229
- // see https://learn.microsoft.com/nuget/consume-packages/install-use-packages-dotnet-cli
230
- var (exitCode, stdout, stderr) = await ProcessEx.RunAsync("dotnet", $"add {projectPath} package {dependencyName} --version {newDependencyVersion}", workingDirectory: Path.GetDirectoryName(projectPath));
231
- MSBuildHelper.ThrowOnUnauthenticatedFeed(stdout);
232
- if (exitCode != 0)
228
+ var projectDirectory = Path.GetDirectoryName(projectPath)!;
229
+ await MSBuildHelper.SidelineGlobalJsonAsync(projectDirectory, repoRootPath, async () =>
233
230
  {
234
- logger.Log($" Transitive dependency [{dependencyName}/{newDependencyVersion}] was not added.\nSTDOUT:\n{stdout}\nSTDERR:\n{stderr}");
235
- }
231
+ logger.Log($" Adding [{dependencyName}/{newDependencyVersion}] as a top-level package reference.");
232
+
233
+ // see https://learn.microsoft.com/nuget/consume-packages/install-use-packages-dotnet-cli
234
+ var (exitCode, stdout, stderr) = await ProcessEx.RunAsync("dotnet", $"add {projectPath} package {dependencyName} --version {newDependencyVersion}", workingDirectory: projectDirectory);
235
+ MSBuildHelper.ThrowOnUnauthenticatedFeed(stdout);
236
+ if (exitCode != 0)
237
+ {
238
+ logger.Log($" Transitive dependency [{dependencyName}/{newDependencyVersion}] was not added.\nSTDOUT:\n{stdout}\nSTDERR:\n{stderr}");
239
+ }
240
+ }, retainMSBuildSdks: true);
236
241
  }
237
242
 
238
243
  /// <summary>
@@ -302,6 +307,7 @@ internal static class SdkPackageUpdater
302
307
  IDictionary<string, string> peerDependencies,
303
308
  Logger logger)
304
309
  {
310
+
305
311
  var result = TryUpdateDependencyVersion(buildFiles, dependencyName, previousDependencyVersion, newDependencyVersion, logger);
306
312
  if (result == UpdateResult.NotFound)
307
313
  {
@@ -320,7 +326,20 @@ internal static class SdkPackageUpdater
320
326
  {
321
327
  foreach (string tfm in targetFrameworks)
322
328
  {
323
- Dependency[]? resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(repoRootPath, projectFile.Path, tfm, updatedTopLevelDependencies, logger);
329
+ if (MSBuildHelper.UseNewDependencySolver())
330
+ {
331
+ // Find the index of the dependency we are updating and revert it to the previous version
332
+ int dependencyIndex = Array.FindIndex(updatedTopLevelDependencies, d => string.Equals(d.Name, dependencyName, StringComparison.OrdinalIgnoreCase));
333
+ if (dependencyIndex != -1)
334
+ {
335
+ var originalDependency = updatedTopLevelDependencies[dependencyIndex];
336
+ updatedTopLevelDependencies[dependencyIndex] = originalDependency with { Version = previousDependencyVersion };
337
+ }
338
+
339
+ }
340
+ Dependency[] update = [new Dependency(dependencyName, newDependencyVersion, DependencyType.PackageReference)];
341
+ Dependency[]? resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(repoRootPath, projectFile.Path, tfm, updatedTopLevelDependencies, update, logger);
342
+
324
343
  if (resolvedDependencies is null)
325
344
  {
326
345
  logger.Log($" Unable to resolve dependency conflicts for {projectFile.Path}.");
@@ -341,7 +360,7 @@ internal static class SdkPackageUpdater
341
360
  continue;
342
361
  }
343
362
 
344
- // update all other dependencies
363
+ // update all dependencies
345
364
  foreach (Dependency resolvedDependency in resolvedDependencies
346
365
  .Where(d => !d.Name.Equals(dependencyName, StringComparison.OrdinalIgnoreCase))
347
366
  .Where(d => d.Version is not null))