dependabot-nuget 0.403.0 → 0.405.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 70b41cf5ca1d42b9d660ec764608de4bc6810788b05b0f2e9d6c03eefd90f277
4
- data.tar.gz: c437530231b3a4991a98d6f9f6783b45f97e40529610676a920a19258f92ceca
3
+ metadata.gz: 76d0ffdd404ccec8cee7288d554cfebc99b40acfcdb59b2bf908e454615bd4cc
4
+ data.tar.gz: 8c8bb04b41d766298a5ecc5ed3cc5d8b24fb83d60f1d6fbd47126514d97398bf
5
5
  SHA512:
6
- metadata.gz: 3959f15dd5206ef05509dbf432ce41fdcf9a73fdb9bf49872d0f251368bb958a46a3687c18050ce1d26dc848de5b583a6d46853eb1190a3b6476ac700fa4f62c
7
- data.tar.gz: f49fa46553521a7bc9635ba0df71993c4fd677f9527b3c59bf3022813dc99c4d7642515e18971c8ec9fe6842393f3eb87179ca6dcea14364c2246bf5016399a3
6
+ metadata.gz: e2f8579eb9d66ace7164fdf4d9495824ba5ef025b9db46c4195c094af634b5c959fa92b0153190faec63679a0dc57115ac33eb84c2568ee99e1bcdc4fa2f2f26
7
+ data.tar.gz: e970e586e84299e5b607a9f9cfbfae23cb188b7a89b7bd7bffe44330bb974fa9e309ad75f84cb5e612b4d9e950f95b913d982b660532293994cdd3c96467a542
@@ -137,7 +137,10 @@ internal static class CompatibilityChecker
137
137
  return true;
138
138
  }
139
139
 
140
- var incompatibleFrameworks = projectFrameworks.Where(f => !compatibleFrameworks.Contains(f)).ToArray();
140
+ var incompatibleFrameworks = projectFrameworks.Where(projectFramework =>
141
+ !compatibleFrameworks.Contains(projectFramework)
142
+ && !packageFrameworks.Any(packageFramework =>
143
+ DefaultCompatibilityProvider.Instance.IsCompatible(projectFramework, packageFramework))).ToArray();
141
144
  if (incompatibleFrameworks.Length > 0)
142
145
  {
143
146
  logger.Info($"The package {package} is not compatible. Incompatible project frameworks: {string.Join(", ", incompatibleFrameworks.Select(f => f.GetShortFolderName()))}");
@@ -329,15 +329,20 @@ internal static class VersionFinder
329
329
  var isMajorBump = version.Major > currentVersion.Major;
330
330
  var isMinorBump = version.Major == currentVersion.Major && version.Minor > currentVersion.Minor;
331
331
  var isPatchBump = version.Major == currentVersion.Major && version.Minor == currentVersion.Minor && version.Patch > currentVersion.Patch;
332
+
333
+ // each ignored update type only rejects bumps of exactly that type, e.g., ignoring `semver-patch`
334
+ // still allows minor and major bumps; this matches the ignore ranges of the other ecosystems and is
335
+ // required for groups, whose `update-types` are forwarded as the ignored complement (a group with
336
+ // `update-types: [major]` ignores `semver-minor` and `semver-patch`, but must still find major bumps)
332
337
  foreach (var ignoreType in dependencyInfo.IgnoredUpdateTypes)
333
338
  {
334
339
  switch (ignoreType)
335
340
  {
336
341
  case ConditionUpdateType.SemVerPatch:
337
- isIgnoredByType = isIgnoredByType || isPatchBump || isMinorBump || isMajorBump;
342
+ isIgnoredByType = isIgnoredByType || isPatchBump;
338
343
  break;
339
344
  case ConditionUpdateType.SemVerMinor:
340
- isIgnoredByType = isIgnoredByType || isMinorBump || isMajorBump;
345
+ isIgnoredByType = isIgnoredByType || isMinorBump;
341
346
  break;
342
347
  case ConditionUpdateType.SemVerMajor:
343
348
  isIgnoredByType = isIgnoredByType || isMajorBump;
@@ -54,24 +54,20 @@ internal static class SdkProjectDiscovery
54
54
  "web.config",
55
55
  };
56
56
 
57
- // these are the targets that are necessary to evaluate for a single restore operation
58
- private static readonly ImmutableArray<string> SingleRestoreTargetNames =
57
+ private static readonly ImmutableArray<string> DiscoveryTargetNames =
59
58
  [
60
- "Restore",
61
59
  "ResolveProjectReferences",
62
60
  "GenerateBuildDependencyFile"
63
61
  ];
64
62
 
65
- // these targets are required to evaluate a legacy project with a single operation
66
- private static readonly ImmutableArray<string> LegacyProjectSingleRestoreTargetNames = ["ResolveProjectReferences"];
63
+ private static readonly ImmutableArray<string> LegacyProjectDiscoveryTargetNames = ["ResolveProjectReferences"];
67
64
 
68
65
  private const string TargetFrameworksPropertyName = "TargetFrameworks";
69
66
 
70
67
  // this property evaluates to a version number in an SDK-style project and is unset or empty otherwise
71
68
  private const string NETCoreSdkVersionPropertyName = "NETCoreSdkVersion";
72
69
 
73
- // this seems to be the maximum number of TFMs that can be restored in parallel without running into race conditions
74
- private const int MaximumParallelTargetFrameworkRestores = 2;
70
+ private const int MaximumParallelTargetFrameworkEvaluations = 2;
75
71
 
76
72
  public static async Task<ImmutableArray<ProjectDiscoveryResult>> DiscoverAsync(string repoRootPath, string workspacePath, string startingProjectPath, ExperimentsManager experimentsManager, string? solutionDir, ILogger logger)
77
73
  {
@@ -130,51 +126,84 @@ internal static class SdkProjectDiscovery
130
126
  var netCoreSdkVersionValue = startingProjectProperties?.GetValueOrDefault(NETCoreSdkVersionPropertyName);
131
127
  var isLegacyProject = string.IsNullOrEmpty(netCoreSdkVersionValue);
132
128
  var requiredTargets = isLegacyProject
133
- ? LegacyProjectSingleRestoreTargetNames
134
- : SingleRestoreTargetNames;
129
+ ? LegacyProjectDiscoveryTargetNames
130
+ : DiscoveryTargetNames;
135
131
 
136
132
  // due to how MSBuild handles multi-TFM projects with target platforms we may need to process each TFM separately
137
133
  // we detect that by determining if there are multiple target frameworks specified and if any of them have a platform suffix (e.g., `-windows`, `-android`, etc)
138
134
  // alternately, if there are too many target frameworks specified, they must be handled individually
139
135
  var hasPlatformTfms = projectTfms.Any(tfm => tfm.Contains('-'));
140
- var requiresIndividualRestores = hasPlatformTfms || projectTfms.Length > MaximumParallelTargetFrameworkRestores;
141
- var useDirectRestore = requiresIndividualRestores;
142
- if (!requiresIndividualRestores)
136
+ var requiresIndividualEvaluations = hasPlatformTfms || projectTfms.Length > MaximumParallelTargetFrameworkEvaluations;
137
+ var useDirectEvaluation = requiresIndividualEvaluations;
138
+ if (!requiresIndividualEvaluations)
143
139
  {
144
- logger.Info($"Performing single restore for project {startingProjectPath}");
145
- projectTfms = [string.Empty]; // a single restore can handle everything, but we need to loop at least once and an empty TFM is our signal to not specify anything
140
+ logger.Info($"Performing single evaluation for project {startingProjectPath}");
141
+ projectTfms = [string.Empty]; // an empty TFM lets the outer build evaluate all target frameworks
146
142
  var actualTargets = await MSBuildHelper.GetProjectTargetsAsync(startingProjectPath, logger);
147
- useDirectRestore = requiredTargets.All(actualTargets.Contains);
143
+ useDirectEvaluation = requiredTargets.All(actualTargets.Contains);
148
144
  }
149
145
  else
150
146
  {
151
- logger.Info($"Performing individual restores for project {startingProjectPath} using target frameworks {string.Join(", ", projectTfms)}");
147
+ logger.Info($"Performing individual evaluations for project {startingProjectPath} using target frameworks {string.Join(", ", projectTfms)}");
148
+ }
149
+
150
+ var commonArgs = new List<string>() { startingProjectPath };
151
+ commonArgs.Add($"/p:ProjectReferenceBuildTargets=\"{string.Join(";", requiredTargets)}\"");
152
+ var dependencyDiscoveryTargetingPacksPropsPath = MSBuildHelper.GetFileFromRuntimeDirectory("DependencyDiscoveryTargetingPacks.props");
153
+ var dependencyDiscoveryTargetsPath = MSBuildHelper.GetFileFromRuntimeDirectory("DependencyDiscovery.targets");
154
+ commonArgs.Add($"/p:CustomBeforeMicrosoftCommonProps={dependencyDiscoveryTargetingPacksPropsPath}");
155
+ commonArgs.Add($"/p:CustomAfterMicrosoftCommonCrossTargetingTargets={dependencyDiscoveryTargetsPath}");
156
+ commonArgs.Add($"/p:CustomAfterMicrosoftCommonTargets={dependencyDiscoveryTargetsPath}");
157
+ if (solutionDir is not null)
158
+ {
159
+ var normalizedSolutionDir = $"{solutionDir.TrimEnd('/', Path.DirectorySeparatorChar)}/";
160
+ commonArgs.Add($"/p:SolutionDir={normalizedSolutionDir}");
161
+ }
162
+ commonArgs.Add("/p:TreatWarningsAsErrors=false");
163
+ commonArgs.Add("/p:MSBuildTreatWarningsAsErrors=false");
164
+
165
+ async Task<(int ExitCode, string Output, string Error)> RunMSBuildAsync(List<string> args)
166
+ {
167
+ var result = await ProcessEx.RunDotnetMSBuildSafelyAsync(args, startingProjectDirectory);
168
+ if (result.ExitCode != 0 && result.Output.Contains("error : Object reference not set to an instance of an object."))
169
+ {
170
+ // https://github.com/NuGet/Home/issues/11761#issuecomment-1105218996
171
+ args.Add("/RestoreProperty:__Unused__=__Unused__");
172
+ result = await ProcessEx.RunDotnetMSBuildSafelyAsync(args, startingProjectDirectory);
173
+ }
174
+
175
+ MSBuildHelper.ThrowOnError(result.Output);
176
+ MSBuildHelper.ThrowOnError(result.Error);
177
+ return result;
178
+ }
179
+
180
+ if (!isLegacyProject)
181
+ {
182
+ // Restore the graph before inner builds introduce a TargetFramework global property.
183
+ var (exitCode, stdOut, stdErr) = await RunMSBuildAsync([.. commonArgs, "/t:Restore"]);
184
+ if (exitCode != 0)
185
+ {
186
+ logger.Warn($"Error restoring dependencies.\nSTDOUT:\n{stdOut}\nSTDERR:\n{stdErr}");
187
+ if (stdErr.Contains("A compatible .NET SDK was not found."))
188
+ {
189
+ throw new Exception("Missing SDK, check global.json locations vs. job directories.");
190
+ }
191
+ }
152
192
  }
153
193
 
154
194
  foreach (var tfm in projectTfms)
155
195
  {
156
- var isIndividualTfmRestore = !string.IsNullOrEmpty(tfm);
196
+ var isIndividualTfmEvaluation = !string.IsNullOrEmpty(tfm);
157
197
 
158
198
  // create a binlog
159
199
  var binLogPath = Path.Combine(Path.GetTempPath(), $"msbuild_{Guid.NewGuid():d}.binlog");
160
200
  try
161
201
  {
162
- // when using single restore, we can directly invoke the relevant targets...
163
- var args = new List<string>() { startingProjectPath };
164
-
165
- // ...but determining what the relevant targets are can be complicated
166
-
167
- // For SDK-style projects the targets `Restore`, `ResolveProjectReferences`, and `GenerateBuildDependencyFile`
168
- // are necessary. If the project has a single target framework, those magic targets will all be present and can
169
- // be directly invoked, but if the project has multiple target frameworks, those targets will _NOT_ be directly
170
- // present and we instead have to invoke the `Build` target and specify the three magic values as `InnerTargets`.
171
-
172
- // If the project is legacy then those three magic targets will not be present, but we shouldn't use the `Build`
173
- // and `InnerTargets` trick because that's an SDK-only mechanism, so we instead only need to invoke
174
- // `ResolveProjectReferences` to gather all `PackageReference` items and further down we re-build the transitive
175
- // dependency set. Without the legacy project check, we could incorrectly invoke `Build` which eventually tries
176
- // to call `csc.exe` which is unnecessary and can be slow.
177
- if (useDirectRestore)
202
+ var args = new List<string>(commonArgs);
203
+
204
+ // Cross-targeting SDK builds dispatch discovery targets through InnerTargets.
205
+ // Legacy projects must invoke their targets directly to avoid compiling them.
206
+ if (useDirectEvaluation)
178
207
  {
179
208
  // directly call the required targets
180
209
  args.Add($"/t:{string.Join(",", requiredTargets)}");
@@ -186,48 +215,14 @@ internal static class SdkProjectDiscovery
186
215
  args.Add($"/p:InnerTargets=\"{string.Join(";", requiredTargets)}\"");
187
216
  }
188
217
 
189
- // only execute the desired targets on transitive project references
190
- args.Add($"/p:ProjectReferenceBuildTargets=\"{string.Join(";", requiredTargets)}\"");
191
-
192
- // inject various props and targets to help with discovery
193
- var dependencyDiscoveryTargetingPacksPropsPath = MSBuildHelper.GetFileFromRuntimeDirectory("DependencyDiscoveryTargetingPacks.props");
194
- var dependencyDiscoveryTargetsPath = MSBuildHelper.GetFileFromRuntimeDirectory("DependencyDiscovery.targets");
195
- args.Add($"/p:CustomBeforeMicrosoftCommonProps={dependencyDiscoveryTargetingPacksPropsPath}");
196
- args.Add($"/p:CustomAfterMicrosoftCommonCrossTargetingTargets={dependencyDiscoveryTargetsPath}");
197
- args.Add($"/p:CustomAfterMicrosoftCommonTargets={dependencyDiscoveryTargetsPath}");
198
-
199
- if (isIndividualTfmRestore)
218
+ if (isIndividualTfmEvaluation)
200
219
  {
201
220
  args.Add($"/p:TargetFramework={tfm}");
202
221
  }
203
222
 
204
- // if the project lives alongside a solution file, fake the MSBuild `SolutionDir` property so that
205
- // project files referencing `$(SolutionDir)` can be evaluated correctly; MSBuild expects this value
206
- // to end with a directory separator so that `$(SolutionDir)foo` concatenations form valid paths
207
- if (solutionDir is not null)
208
- {
209
- var normalizedSolutionDir = $"{solutionDir.TrimEnd('/', Path.DirectorySeparatorChar)}/";
210
- args.Add($"/p:SolutionDir={normalizedSolutionDir}");
211
- }
212
-
213
- // if using CPM and a project also sets TreatWarningsAsErrors to true, this can cause discovery to fail; explicitly don't allow that
214
- args.Add("/p:TreatWarningsAsErrors=false");
215
- args.Add("/p:MSBuildTreatWarningsAsErrors=false");
216
223
  args.Add($"/bl:{binLogPath}");
217
224
 
218
- var (exitCode, stdOut, stdErr) = await ProcessEx.RunDotnetMSBuildSafelyAsync(args, startingProjectDirectory);
219
- if (exitCode != 0 && stdOut.Contains("error : Object reference not set to an instance of an object."))
220
- {
221
- // https://github.com/NuGet/Home/issues/11761#issuecomment-1105218996
222
- // Due to a bug in NuGet, there can be a null reference exception thrown and adding this command line argument will work around it,
223
- // but this argument can't always be added; it can cause problems in other instances, so we're taking the approach of not using it
224
- // unless we have to.
225
- args.Add("/RestoreProperty:__Unused__=__Unused__");
226
- (exitCode, stdOut, stdErr) = await ProcessEx.RunDotnetMSBuildSafelyAsync(args, startingProjectDirectory);
227
- }
228
-
229
- MSBuildHelper.ThrowOnError(stdOut);
230
- MSBuildHelper.ThrowOnError(stdErr);
225
+ var (exitCode, stdOut, stdErr) = await RunMSBuildAsync(args);
231
226
  if (exitCode != 0)
232
227
  {
233
228
  // log error, but still try to resolve what we can
@@ -547,7 +542,8 @@ internal static class SdkProjectDiscovery
547
542
  {
548
543
  if (!File.Exists(assetsFilePath))
549
544
  {
550
- throw new FileNotFoundException("The file specified at $(ProjectAssetsFile) does not exist.");
545
+ // A failed restore can leave no assets; retain dependencies discovered from the build.
546
+ return null;
551
547
  }
552
548
 
553
549
  var assetsContent = File.ReadAllText(assetsFilePath);
@@ -31,6 +31,10 @@ internal class RefreshSecurityUpdatePullRequestHandler : IUpdateHandler
31
31
  var repoContentsPath = caseInsensitiveRepoContentsPath ?? originalRepoContentsPath;
32
32
  var jobDependencies = job.Dependencies.ToHashSet(StringComparer.OrdinalIgnoreCase);
33
33
  var initialFiles = ModifiedFilesTracker.GetInitiallyExistingFiles(repoContentsPath);
34
+ // directories share a working tree, so an earlier directory may already have updated (or created) the PR
35
+ var pullRequestUpdated = false;
36
+ // closing is deferred until every directory has been evaluated so the outcome doesn't depend on directory order
37
+ ClosePullRequest? pendingClose = null;
34
38
  foreach (var directory in job.GetAllDirectories(repoContentsPath.FullName))
35
39
  {
36
40
  var discoveryResult = await discoveryWorker.RunAsync(repoContentsPath.FullName, directory);
@@ -59,8 +63,7 @@ internal class RefreshSecurityUpdatePullRequestHandler : IUpdateHandler
59
63
  if (groupedUpdateOperationsToPerform.Count == 0)
60
64
  {
61
65
  var close = ClosePullRequest.WithDependenciesRemoved(job);
62
- logger.Info(close.GetReport());
63
- await apiHandler.ClosePullRequest(close);
66
+ pendingClose ??= close;
64
67
  continue;
65
68
  }
66
69
 
@@ -71,11 +74,11 @@ internal class RefreshSecurityUpdatePullRequestHandler : IUpdateHandler
71
74
  if (missingDependencies.Length > 0)
72
75
  {
73
76
  var close = ClosePullRequest.WithDependencyRemoved(job);
74
- logger.Info(close.GetReport());
75
- await apiHandler.ClosePullRequest(close);
77
+ pendingClose ??= close;
76
78
  continue;
77
79
  }
78
80
 
81
+ var noVulnerableDependencies = false;
79
82
  var tracker = new ModifiedFilesTracker(originalRepoContentsPath, initialFiles, logger);
80
83
  await tracker.StartTrackingAsync(discoveryResult);
81
84
  foreach (var dependencyGroupToUpdate in groupedUpdateOperationsToPerform)
@@ -90,9 +93,9 @@ internal class RefreshSecurityUpdatePullRequestHandler : IUpdateHandler
90
93
  if (vulnerableDependenciesToUpdate.Length == 0)
91
94
  {
92
95
  var close = ClosePullRequest.WithUpToDate(job);
93
- logger.Info(close.GetReport());
94
- await apiHandler.ClosePullRequest(close);
95
- return;
96
+ pendingClose ??= close;
97
+ noVulnerableDependencies = true;
98
+ break;
96
99
  }
97
100
 
98
101
  foreach (var (projectPath, dependency, dependencyInfo) in vulnerableDependenciesToUpdate)
@@ -141,6 +144,11 @@ internal class RefreshSecurityUpdatePullRequestHandler : IUpdateHandler
141
144
  }
142
145
  }
143
146
 
147
+ if (noVulnerableDependencies)
148
+ {
149
+ continue;
150
+ }
151
+
144
152
  // ensure we did something
145
153
  var updatesNotPerformed = jobDependencies
146
154
  .Except(updatedDependencies.Select(d => d.Name), StringComparer.OrdinalIgnoreCase)
@@ -151,7 +159,7 @@ internal class RefreshSecurityUpdatePullRequestHandler : IUpdateHandler
151
159
  if (updatesNotPerformed.Length > 0)
152
160
  {
153
161
  logger.Info($"No updates performed for: {string.Join(", ", updatesNotPerformed)}");
154
- await apiHandler.ClosePullRequest(ClosePullRequest.WithUpdateNoLongerPossible(job));
162
+ pendingClose ??= ClosePullRequest.WithUpdateNoLongerPossible(job);
155
163
  continue;
156
164
  }
157
165
 
@@ -178,6 +186,7 @@ internal class RefreshSecurityUpdatePullRequestHandler : IUpdateHandler
178
186
  PrTitle = prTitle,
179
187
  PrBody = prBody,
180
188
  });
189
+ pullRequestUpdated = true;
181
190
  continue;
182
191
  }
183
192
  else
@@ -198,9 +207,16 @@ internal class RefreshSecurityUpdatePullRequestHandler : IUpdateHandler
198
207
  PrBody = prBody,
199
208
  DependencyGroup = null,
200
209
  });
210
+ pullRequestUpdated = true;
201
211
  continue;
202
212
  }
203
213
  }
204
214
  }
215
+
216
+ if (!pullRequestUpdated && pendingClose is not null)
217
+ {
218
+ logger.Info(pendingClose.GetReport());
219
+ await apiHandler.ClosePullRequest(pendingClose);
220
+ }
205
221
  }
206
222
  }
@@ -31,6 +31,10 @@ internal class RefreshVersionUpdatePullRequestHandler : IUpdateHandler
31
31
  var repoContentsPath = caseInsensitiveRepoContentsPath ?? originalRepoContentsPath;
32
32
  var jobDependencies = job.Dependencies.ToHashSet(StringComparer.OrdinalIgnoreCase);
33
33
  var initialFiles = ModifiedFilesTracker.GetInitiallyExistingFiles(repoContentsPath);
34
+ // directories share a working tree, so an earlier directory may already have updated (or created) the PR
35
+ var pullRequestUpdated = false;
36
+ // closing is deferred until every directory has been evaluated so the outcome doesn't depend on directory order
37
+ ClosePullRequest? pendingClose = null;
34
38
  foreach (var directory in job.GetAllDirectories(repoContentsPath.FullName))
35
39
  {
36
40
  var discoveryResult = await discoveryWorker.RunAsync(repoContentsPath.FullName, directory);
@@ -56,8 +60,7 @@ internal class RefreshVersionUpdatePullRequestHandler : IUpdateHandler
56
60
  if (relevantUpdateOperationsToPerform.Count == 0)
57
61
  {
58
62
  var close = ClosePullRequest.WithDependenciesRemoved(job);
59
- logger.Info(close.GetReport());
60
- await apiHandler.ClosePullRequest(close);
63
+ pendingClose ??= close;
61
64
  continue;
62
65
  }
63
66
 
@@ -68,8 +71,7 @@ internal class RefreshVersionUpdatePullRequestHandler : IUpdateHandler
68
71
  if (missingDependencies.Length > 0)
69
72
  {
70
73
  var close = ClosePullRequest.WithDependencyRemoved(job);
71
- logger.Info(close.GetReport());
72
- await apiHandler.ClosePullRequest(close);
74
+ pendingClose ??= close;
73
75
  continue;
74
76
  }
75
77
 
@@ -141,7 +143,7 @@ internal class RefreshVersionUpdatePullRequestHandler : IUpdateHandler
141
143
  if (updatesNotPerformed.Length > 0)
142
144
  {
143
145
  logger.Info($"No updates performed for: {string.Join(", ", updatesNotPerformed)}");
144
- await apiHandler.ClosePullRequest(ClosePullRequest.WithUpdateNoLongerPossible(job));
146
+ pendingClose ??= ClosePullRequest.WithUpdateNoLongerPossible(job);
145
147
  continue;
146
148
  }
147
149
 
@@ -168,6 +170,7 @@ internal class RefreshVersionUpdatePullRequestHandler : IUpdateHandler
168
170
  PrTitle = prTitle,
169
171
  PrBody = prBody,
170
172
  });
173
+ pullRequestUpdated = true;
171
174
  continue;
172
175
  }
173
176
  else
@@ -188,9 +191,16 @@ internal class RefreshVersionUpdatePullRequestHandler : IUpdateHandler
188
191
  PrBody = prBody,
189
192
  DependencyGroup = null,
190
193
  });
194
+ pullRequestUpdated = true;
191
195
  continue;
192
196
  }
193
197
  }
194
198
  }
199
+
200
+ if (!pullRequestUpdated && pendingClose is not null)
201
+ {
202
+ logger.Info(pendingClose.GetReport());
203
+ await apiHandler.ClosePullRequest(pendingClose);
204
+ }
195
205
  }
196
206
  }
@@ -211,6 +211,36 @@ public class CompatibilityCheckerTests
211
211
  Assert.True(isCompatible);
212
212
  }
213
213
 
214
+ [Theory]
215
+ [InlineData("net10.0-windows", "net10.0", true)]
216
+ [InlineData("net10.0-windows7.0", "net10.0", true)]
217
+ [InlineData("net10.0-windows10.0.19041", "net10.0", true)]
218
+ [InlineData("net10.0-ios18.0", "net10.0", true)]
219
+ [InlineData("net10.0-windows10.0.19041", "net10.0-windows10.0.17763", true)]
220
+ [InlineData("net10.0-windows10.0.17763", "net10.0-windows10.0.19041", false)]
221
+ [InlineData("net10.0", "net10.0-windows", false)]
222
+ [InlineData("net10.0-windows", "net11.0", false)]
223
+ public async Task CheckAsync_PackageWithLibAssembly_ChecksPlatformCompatibility(
224
+ string projectTfm,
225
+ string packageTfm,
226
+ bool expectedCompatible)
227
+ {
228
+ using var tempDir = new TemporaryDirectory();
229
+ var package = MockNuGetPackage.CreateSimplePackage("Some.Package", "1.0.0", packageTfm);
230
+ await UpdateWorkerTestBase.MockNuGetPackagesInDirectory([package], tempDir.DirectoryPath, includeCommonPackages: false);
231
+ var packageId = new PackageIdentity(package.Id, NuGetVersion.Parse(package.Version));
232
+ using var context = new NuGetContext(tempDir.DirectoryPath, NuGet.Common.NullLogger.Instance);
233
+
234
+ var isCompatible = await CompatibilityChecker.CheckAsync(
235
+ packageId,
236
+ [NuGetFramework.Parse(projectTfm)],
237
+ context,
238
+ new TestLogger(),
239
+ TestContext.Current.CancellationToken);
240
+
241
+ Assert.Equal(expectedCompatible, isCompatible);
242
+ }
243
+
214
244
  [Fact]
215
245
  public async Task ExistsAndIsCompatibleAsync_ExistingPackageWithoutProjectFrameworks_ReportsAsCompatible()
216
246
  {
@@ -341,11 +341,16 @@ public class VersionFinderTests : TestBase
341
341
  }
342
342
 
343
343
  [Theory]
344
- [InlineData(null, "1.0.1", "1.1.0", "2.0.0")]
345
- [InlineData(ConditionUpdateType.SemVerMajor, "1.0.1", "1.1.0")]
346
- [InlineData(ConditionUpdateType.SemVerMinor, "1.0.1")]
347
- [InlineData(ConditionUpdateType.SemVerPatch)]
348
- public async Task VersionFinder_IgnoredUpdateTypesIsHonored(ConditionUpdateType? ignoredUpdateType, params string[] expectedVersions)
344
+ [InlineData(new ConditionUpdateType[0], new[] { "1.0.1", "1.1.0", "2.0.0" })]
345
+ [InlineData(new[] { ConditionUpdateType.SemVerMajor }, new[] { "1.0.1", "1.1.0" })]
346
+ [InlineData(new[] { ConditionUpdateType.SemVerMinor }, new[] { "1.0.1", "2.0.0" })]
347
+ [InlineData(new[] { ConditionUpdateType.SemVerPatch }, new[] { "1.1.0", "2.0.0" })]
348
+ [InlineData(new[] { ConditionUpdateType.SemVerMajor, ConditionUpdateType.SemVerMinor }, new[] { "1.0.1" })]
349
+ [InlineData(new[] { ConditionUpdateType.SemVerMajor, ConditionUpdateType.SemVerPatch }, new[] { "1.1.0" })]
350
+ // this is what a group with `update-types: [major]` forwards
351
+ [InlineData(new[] { ConditionUpdateType.SemVerMinor, ConditionUpdateType.SemVerPatch }, new[] { "2.0.0" })]
352
+ [InlineData(new[] { ConditionUpdateType.SemVerMajor, ConditionUpdateType.SemVerMinor, ConditionUpdateType.SemVerPatch }, new string[0])]
353
+ public async Task VersionFinder_IgnoredUpdateTypesIsHonored(ConditionUpdateType[] ignoredUpdateTypes, string[] expectedVersions)
349
354
  {
350
355
  // arrange
351
356
  using var tempDir = new TemporaryDirectory();
@@ -355,9 +360,6 @@ public class VersionFinderTests : TestBase
355
360
  MockNuGetPackage.CreateSimplePackage("Some.Dependency", "2.0.0", "net9.0"),
356
361
  ], tempDir.DirectoryPath);
357
362
  var tfm = NuGetFramework.Parse("net9.0");
358
- var ignoredUpdateTypes = ignoredUpdateType is not null
359
- ? new ConditionUpdateType[] { ignoredUpdateType.Value }
360
- : [];
361
363
  var dependencyInfo = new DependencyInfo()
362
364
  {
363
365
  Name = "Some.Dependency",
@@ -339,10 +339,15 @@ public partial class DiscoveryWorkerTests
339
339
  FilePath = "myproj.csproj",
340
340
  TargetFrameworks = ["net48"],
341
341
  Dependencies = [
342
+ new("PackageOnlyCompatibleWithNet8", "2.0.0", DependencyType.PackageReference, TargetFrameworks: ["net48"]),
342
343
  new("PackageReferencedThroughLegacyMechanism", "1.0.0", DependencyType.PackagesConfig, TargetFrameworks: ["net48"]),
343
344
  ],
344
345
  ReferencedProjectPaths = [],
345
- ImportedFiles = [],
346
+ ImportedFiles = [
347
+ "../Directory.Build.props",
348
+ "../Directory.Build.targets",
349
+ "../Directory.Packages.props",
350
+ ],
346
351
  AdditionalFiles = [
347
352
  "packages.config"
348
353
  ],
@@ -377,6 +377,51 @@ public class SdkProjectDiscoveryTests : DiscoveryWorkerTestBase
377
377
  );
378
378
  }
379
379
 
380
+ [Fact]
381
+ public async Task DiscoveryContinuesAfterPartialRestoreFailure()
382
+ {
383
+ using var testDirectory = await TemporaryDirectory.CreateWithContentsAsync(
384
+ ("library.csproj", """
385
+ <Project Sdk="Microsoft.NET.Sdk">
386
+ <PropertyGroup>
387
+ <TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
388
+ </PropertyGroup>
389
+ <ItemGroup>
390
+ <PackageReference Include="Some.Dependency" Version="1.2.3" />
391
+ </ItemGroup>
392
+ </Project>
393
+ """));
394
+ await UpdateWorkerTestBase.MockNuGetPackagesInDirectory(
395
+ [
396
+ MockNuGetPackage.CreateSimplePackage("Some.Dependency", "1.2.3", "net9.0",
397
+ [(null, [("Transitive.Dependency", "4.5.6")])]),
398
+ MockNuGetPackage.CreateSimplePackage("Transitive.Dependency", "4.5.6", "net9.0"),
399
+ ],
400
+ testDirectory.DirectoryPath);
401
+ var projectPath = Path.Combine(testDirectory.DirectoryPath, "library.csproj");
402
+ var (exitCode, output, _) = await ProcessEx.RunDotnetWithoutMSBuildEnvironmentVariablesAsync(
403
+ ["restore", projectPath], testDirectory.DirectoryPath);
404
+ Assert.NotEqual(0, exitCode);
405
+ Assert.Contains("NU1202", output);
406
+
407
+ var projects = await SdkProjectDiscovery.DiscoverAsync(
408
+ testDirectory.DirectoryPath,
409
+ testDirectory.DirectoryPath,
410
+ projectPath,
411
+ new ExperimentsManager(),
412
+ solutionDir: null,
413
+ new TestLogger());
414
+
415
+ var project = Assert.Single(projects);
416
+ foreach (var tfm in new[] { "net9.0", "net10.0" })
417
+ {
418
+ Assert.Contains(project.Dependencies, d => d.Name == "Some.Dependency" &&
419
+ d.Version == "1.2.3" && d.TargetFrameworks?.Contains(tfm) == true && d.IsTopLevel);
420
+ Assert.Contains(project.Dependencies, d => d.Name == "Transitive.Dependency" &&
421
+ d.Version == "4.5.6" && d.TargetFrameworks?.Contains(tfm) == true && !d.IsTopLevel);
422
+ }
423
+ }
424
+
380
425
  [Fact]
381
426
  public async Task DiscoveryIgnoresNetStandardLibrary()
382
427
  {