dependabot-nuget 0.294.0 → 0.296.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: 97e76c69b2fed1672ebe1e9b3b890e8f445139f26729895c72a196d49cd43d63
4
- data.tar.gz: 10ef8cb4d30c84e9e8f51fdc5bf4f529b451936ad8a34e905e69fbaa0b813cac
3
+ metadata.gz: 22109eb4de3c3d7317682ad493e6162a7af4328e07751a27c8dbb48978597ef3
4
+ data.tar.gz: 9a8afdc613b3313c7e08ac3967c4abd311a6eb66a662022677bed40229e52d3b
5
5
  SHA512:
6
- metadata.gz: 73cdefd4ef762621a7142a040a747011ee4a390635379ee311deccaf6664062834a8e809b6203816e81f8ebb24ed10f68d04975e9bcde40e5ffd2d3720779c68
7
- data.tar.gz: a8cde74fdb1b400ced101cac7132bb32c8dc6b3d36ff6c249908e33e9e8c719e63999c02982ba2bf7704b18007be0daac14dcdd6c39ba74c4a8c38ccad2ae11e
6
+ metadata.gz: fe8805919ec14b5bf6385d4bb4ff3a1dc00137fc08c1e002d8c3db0600c4e5c2e8e86319d3e40fe4c608d29229834c3c741fa8a262b3e8d9f9c8e21755cf9029
7
+ data.tar.gz: d0b247df044695e253e08ed9cabbdea0341ff9234ca601c61fc48d2f13ac138ffce51683ebf45ed37478190750a791bacbc3308ab0a69e3cff70e61cffb8576a
@@ -262,7 +262,8 @@ public partial class DiscoveryWorker : IDiscoveryWorker
262
262
  }
263
263
  }
264
264
 
265
- return expandedProjects.ToImmutableArray();
265
+ var result = expandedProjects.OrderBy(p => p).ToImmutableArray();
266
+ return result;
266
267
  }
267
268
 
268
269
  private static IEnumerable<string> ExpandItemGroupFilesFromProject(string projectPath, params string[] itemTypes)
@@ -114,7 +114,7 @@ internal static class SdkProjectDiscovery
114
114
  var (exitCode, stdOut, stdErr) = await ProcessEx.RunDotnetWithoutMSBuildEnvironmentVariablesAsync(args, startingProjectDirectory, experimentsManager);
115
115
  return (exitCode, stdOut, stdErr);
116
116
  }, logger, retainMSBuildSdks: true);
117
- MSBuildHelper.ThrowOnUnauthenticatedFeed(stdOut);
117
+ MSBuildHelper.ThrowOnError(stdOut);
118
118
  if (stdOut.Contains("""error MSB4057: The target "GenerateBuildDependencyFile" does not exist in the project."""))
119
119
  {
120
120
  // this can happen if it's a non-SDK-style project; totally normal, not worth examining the binlog
@@ -62,9 +62,13 @@ public record ExperimentsManager
62
62
  return false;
63
63
  }
64
64
 
65
- if (experiments.TryGetValue(experimentName, out var value))
65
+ // prefer experiments named with underscores, but hyphens are also allowed as an alternate
66
+ object? experimentValue;
67
+ var experimentNameAlternate = experimentName.Replace("_", "-");
68
+ if (experiments.TryGetValue(experimentName, out experimentValue) ||
69
+ experiments.TryGetValue(experimentNameAlternate, out experimentValue))
66
70
  {
67
- if ((value?.ToString() ?? "").Equals("true", StringComparison.OrdinalIgnoreCase))
71
+ if ((experimentValue?.ToString() ?? "").Equals("true", StringComparison.OrdinalIgnoreCase))
68
72
  {
69
73
  return true;
70
74
  }
@@ -4,6 +4,8 @@ using System.Text;
4
4
  using System.Text.Json;
5
5
  using System.Text.Json.Serialization;
6
6
 
7
+ using Microsoft.Extensions.FileSystemGlobbing;
8
+
7
9
  using NuGet.Versioning;
8
10
 
9
11
  using NuGetUpdater.Core.Analyze;
@@ -115,161 +117,145 @@ public class RunWorker
115
117
  await _apiHandler.UpdateDependencyList(discoveredUpdatedDependencies);
116
118
 
117
119
  // TODO: pull out relevant dependencies, then check each for updates and track the changes
118
- // TODO: for each top-level dependency, _or_ specific dependency (if security, use transitive)
119
120
  var originalDependencyFileContents = new Dictionary<string, string>();
120
121
  var actualUpdatedDependencies = new List<ReportedDependency>();
121
- if (job.AllowedUpdates.Any(a => a.UpdateType == UpdateType.All))
122
+ await _apiHandler.IncrementMetric(new()
122
123
  {
123
- await _apiHandler.IncrementMetric(new()
124
- {
125
- Metric = "updater.started",
126
- Tags = { ["operation"] = "group_update_all_versions" },
127
- });
124
+ Metric = "updater.started",
125
+ Tags = { ["operation"] = "group_update_all_versions" },
126
+ });
127
+
128
+ // track original contents for later handling
129
+ async Task TrackOriginalContentsAsync(string directory, string fileName)
130
+ {
131
+ var repoFullPath = Path.Join(directory, fileName).FullyNormalizedRootedPath();
132
+ var localFullPath = Path.Join(repoContentsPath.FullName, repoFullPath);
133
+ var content = await File.ReadAllTextAsync(localFullPath);
134
+ originalDependencyFileContents[repoFullPath] = content;
135
+ }
128
136
 
129
- // track original contents for later handling
130
- async Task TrackOriginalContentsAsync(string directory, string fileName)
137
+ foreach (var project in discoveryResult.Projects)
138
+ {
139
+ var projectDirectory = Path.GetDirectoryName(project.FilePath);
140
+ await TrackOriginalContentsAsync(discoveryResult.Path, project.FilePath);
141
+ foreach (var extraFile in project.ImportedFiles.Concat(project.AdditionalFiles))
131
142
  {
132
- var repoFullPath = Path.Join(directory, fileName).FullyNormalizedRootedPath();
133
- var localFullPath = Path.Join(repoContentsPath.FullName, repoFullPath);
134
- var content = await File.ReadAllTextAsync(localFullPath);
135
- originalDependencyFileContents[repoFullPath] = content;
143
+ var extraFilePath = Path.Join(projectDirectory, extraFile);
144
+ await TrackOriginalContentsAsync(discoveryResult.Path, extraFilePath);
136
145
  }
146
+ // TODO: include global.json, etc.
147
+ }
137
148
 
138
- foreach (var project in discoveryResult.Projects)
149
+ // do update
150
+ _logger.Info($"Running update in directory {repoDirectory}");
151
+ foreach (var project in discoveryResult.Projects)
152
+ {
153
+ foreach (var dependency in project.Dependencies)
139
154
  {
140
- var projectDirectory = Path.GetDirectoryName(project.FilePath);
141
- await TrackOriginalContentsAsync(discoveryResult.Path, project.FilePath);
142
- foreach (var extraFile in project.ImportedFiles.Concat(project.AdditionalFiles))
155
+ if (!IsUpdateAllowed(job, dependency))
143
156
  {
144
- var extraFilePath = Path.Join(projectDirectory, extraFile);
145
- await TrackOriginalContentsAsync(discoveryResult.Path, extraFilePath);
157
+ continue;
146
158
  }
147
- // TODO: include global.json, etc.
148
- }
149
159
 
150
- // do update
151
- _logger.Info($"Running update in directory {repoDirectory}");
152
- foreach (var project in discoveryResult.Projects)
153
- {
154
- foreach (var dependency in project.Dependencies.Where(d => !d.IsTransitive))
160
+ var dependencyInfo = GetDependencyInfo(job, dependency);
161
+ var analysisResult = await _analyzeWorker.RunAsync(repoContentsPath.FullName, discoveryResult, dependencyInfo);
162
+ // TODO: log analysisResult
163
+ if (analysisResult.CanUpdate)
155
164
  {
156
- if (dependency.Name == "Microsoft.NET.Sdk")
157
- {
158
- // this can't be updated
159
- // TODO: pull this out of discovery?
160
- continue;
161
- }
162
-
163
- if (dependency.Version is null)
164
- {
165
- // if we don't know the version, there's nothing we can do
166
- continue;
167
- }
165
+ var dependencyLocation = Path.Join(discoveryResult.Path, project.FilePath).FullyNormalizedRootedPath();
168
166
 
169
- var dependencyInfo = GetDependencyInfo(job, dependency);
170
- var analysisResult = await _analyzeWorker.RunAsync(repoContentsPath.FullName, discoveryResult, dependencyInfo);
171
- // TODO: log analysisResult
172
- if (analysisResult.CanUpdate)
167
+ // TODO: this is inefficient, but not likely causing a bottleneck
168
+ var previousDependency = discoveredUpdatedDependencies.Dependencies
169
+ .Single(d => d.Name == dependency.Name && d.Requirements.Single().File == dependencyLocation);
170
+ var updatedDependency = new ReportedDependency()
173
171
  {
174
- var dependencyLocation = Path.Join(discoveryResult.Path, project.FilePath).FullyNormalizedRootedPath();
175
-
176
- // TODO: this is inefficient, but not likely causing a bottleneck
177
- var previousDependency = discoveredUpdatedDependencies.Dependencies
178
- .Single(d => d.Name == dependency.Name && d.Requirements.Single().File == dependencyLocation);
179
- var updatedDependency = new ReportedDependency()
180
- {
181
- Name = dependency.Name,
182
- Version = analysisResult.UpdatedVersion,
183
- Requirements =
184
- [
185
- new ReportedRequirement()
186
- {
187
- File = dependencyLocation,
188
- Requirement = analysisResult.UpdatedVersion,
189
- Groups = previousDependency.Requirements.Single().Groups,
190
- Source = new RequirementSource()
191
- {
192
- SourceUrl = analysisResult.UpdatedDependencies.FirstOrDefault(d => d.Name == dependency.Name)?.InfoUrl,
193
- },
194
- }
195
- ],
196
- PreviousVersion = dependency.Version,
197
- PreviousRequirements = previousDependency.Requirements,
198
- };
199
-
200
- var dependencyFilePath = Path.Join(discoveryResult.Path, project.FilePath).FullyNormalizedRootedPath();
201
- var updateResult = await _updaterWorker.RunAsync(repoContentsPath.FullName, dependencyFilePath, dependency.Name, dependency.Version!, analysisResult.UpdatedVersion, isTransitive: false);
202
- // TODO: need to report if anything was actually updated
203
- if (updateResult.Error is null)
204
- {
205
- if (dependencyLocation != dependencyFilePath)
172
+ Name = dependency.Name,
173
+ Version = analysisResult.UpdatedVersion,
174
+ Requirements =
175
+ [
176
+ new ReportedRequirement()
206
177
  {
207
- updatedDependency.Requirements.All(r => r.File == dependencyFilePath);
178
+ File = dependencyLocation,
179
+ Requirement = analysisResult.UpdatedVersion,
180
+ Groups = previousDependency.Requirements.Single().Groups,
181
+ Source = new RequirementSource()
182
+ {
183
+ SourceUrl = analysisResult.UpdatedDependencies.FirstOrDefault(d => d.Name == dependency.Name)?.InfoUrl,
184
+ },
208
185
  }
186
+ ],
187
+ PreviousVersion = dependency.Version,
188
+ PreviousRequirements = previousDependency.Requirements,
189
+ };
209
190
 
210
- actualUpdatedDependencies.Add(updatedDependency);
191
+ var dependencyFilePath = Path.Join(discoveryResult.Path, project.FilePath).FullyNormalizedRootedPath();
192
+ var updateResult = await _updaterWorker.RunAsync(repoContentsPath.FullName, dependencyFilePath, dependency.Name, dependency.Version!, analysisResult.UpdatedVersion, isTransitive: dependency.IsTransitive);
193
+ // TODO: need to report if anything was actually updated
194
+ if (updateResult.Error is null)
195
+ {
196
+ if (dependencyLocation != dependencyFilePath)
197
+ {
198
+ updatedDependency.Requirements.All(r => r.File == dependencyFilePath);
211
199
  }
200
+
201
+ actualUpdatedDependencies.Add(updatedDependency);
212
202
  }
213
203
  }
214
204
  }
205
+ }
215
206
 
216
- // create PR - we need to manually check file contents; we can't easily use `git status` in tests
217
- var updatedDependencyFiles = new Dictionary<string, DependencyFile>();
218
- async Task AddUpdatedFileIfDifferentAsync(string directory, string fileName)
207
+ // create PR - we need to manually check file contents; we can't easily use `git status` in tests
208
+ var updatedDependencyFiles = new Dictionary<string, DependencyFile>();
209
+ async Task AddUpdatedFileIfDifferentAsync(string directory, string fileName)
210
+ {
211
+ var repoFullPath = Path.Join(directory, fileName).FullyNormalizedRootedPath();
212
+ var localFullPath = Path.GetFullPath(Path.Join(repoContentsPath.FullName, repoFullPath));
213
+ var originalContent = originalDependencyFileContents[repoFullPath];
214
+ var updatedContent = await File.ReadAllTextAsync(localFullPath);
215
+ if (updatedContent != originalContent)
219
216
  {
220
- var repoFullPath = Path.Join(directory, fileName).FullyNormalizedRootedPath();
221
- var localFullPath = Path.GetFullPath(Path.Join(repoContentsPath.FullName, repoFullPath));
222
- var originalContent = originalDependencyFileContents[repoFullPath];
223
- var updatedContent = await File.ReadAllTextAsync(localFullPath);
224
- if (updatedContent != originalContent)
217
+ updatedDependencyFiles[localFullPath] = new DependencyFile()
225
218
  {
226
- updatedDependencyFiles[localFullPath] = new DependencyFile()
227
- {
228
- Name = Path.GetFileName(repoFullPath),
229
- Directory = Path.GetDirectoryName(repoFullPath)!.NormalizePathToUnix(),
230
- Content = updatedContent,
231
- };
232
- }
219
+ Name = Path.GetFileName(repoFullPath),
220
+ Directory = Path.GetDirectoryName(repoFullPath)!.NormalizePathToUnix(),
221
+ Content = updatedContent,
222
+ };
233
223
  }
224
+ }
234
225
 
235
- foreach (var project in discoveryResult.Projects)
226
+ foreach (var project in discoveryResult.Projects)
227
+ {
228
+ await AddUpdatedFileIfDifferentAsync(discoveryResult.Path, project.FilePath);
229
+ var projectDirectory = Path.GetDirectoryName(project.FilePath);
230
+ foreach (var extraFile in project.ImportedFiles.Concat(project.AdditionalFiles))
236
231
  {
237
- await AddUpdatedFileIfDifferentAsync(discoveryResult.Path, project.FilePath);
238
- var projectDirectory = Path.GetDirectoryName(project.FilePath);
239
- foreach (var extraFile in project.ImportedFiles.Concat(project.AdditionalFiles))
240
- {
241
- var extraFilePath = Path.Join(projectDirectory, extraFile);
242
- await AddUpdatedFileIfDifferentAsync(discoveryResult.Path, extraFilePath);
243
- }
244
- // TODO: handle global.json, etc.
232
+ var extraFilePath = Path.Join(projectDirectory, extraFile);
233
+ await AddUpdatedFileIfDifferentAsync(discoveryResult.Path, extraFilePath);
245
234
  }
235
+ // TODO: handle global.json, etc.
236
+ }
246
237
 
247
- if (updatedDependencyFiles.Count > 0)
248
- {
249
- var updatedDependencyFileList = updatedDependencyFiles
250
- .OrderBy(kvp => kvp.Key)
251
- .Select(kvp => kvp.Value)
252
- .ToArray();
253
- var createPullRequest = new CreatePullRequest()
254
- {
255
- Dependencies = actualUpdatedDependencies.ToArray(),
256
- UpdatedDependencyFiles = updatedDependencyFileList,
257
- BaseCommitSha = baseCommitSha,
258
- CommitMessage = "TODO: message",
259
- PrTitle = "TODO: title",
260
- PrBody = "TODO: body",
261
- };
262
- await _apiHandler.CreatePullRequest(createPullRequest);
263
- // TODO: log updated dependencies to console
264
- }
265
- else
238
+ if (updatedDependencyFiles.Count > 0)
239
+ {
240
+ var updatedDependencyFileList = updatedDependencyFiles
241
+ .OrderBy(kvp => kvp.Key)
242
+ .Select(kvp => kvp.Value)
243
+ .ToArray();
244
+ var createPullRequest = new CreatePullRequest()
266
245
  {
267
- // TODO: log or throw if nothing was updated, but was expected to be
268
- }
246
+ Dependencies = actualUpdatedDependencies.ToArray(),
247
+ UpdatedDependencyFiles = updatedDependencyFileList,
248
+ BaseCommitSha = baseCommitSha,
249
+ CommitMessage = "TODO: message",
250
+ PrTitle = "TODO: title",
251
+ PrBody = "TODO: body",
252
+ };
253
+ await _apiHandler.CreatePullRequest(createPullRequest);
254
+ // TODO: log updated dependencies to console
269
255
  }
270
256
  else
271
257
  {
272
- // TODO: throw if no updates performed
258
+ // TODO: log or throw if nothing was updated, but was expected to be
273
259
  }
274
260
 
275
261
  var result = new RunResult()
@@ -289,6 +275,62 @@ public class RunWorker
289
275
  return result;
290
276
  }
291
277
 
278
+ internal static bool IsUpdateAllowed(Job job, Dependency dependency)
279
+ {
280
+ if (dependency.Name.Equals("Microsoft.NET.Sdk", StringComparison.OrdinalIgnoreCase))
281
+ {
282
+ // this can't be updated
283
+ // TODO: pull this out of discovery?
284
+ return false;
285
+ }
286
+
287
+ if (dependency.Version is null)
288
+ {
289
+ // if we don't know the version, there's nothing we can do
290
+ // TODO: pull this out of discovery?
291
+ return false;
292
+ }
293
+
294
+ var version = NuGetVersion.Parse(dependency.Version);
295
+ var dependencyInfo = GetDependencyInfo(job, dependency);
296
+ var isVulnerable = dependencyInfo.Vulnerabilities.Any(v => v.IsVulnerable(version));
297
+ var allowed = job.AllowedUpdates.Any(allowedUpdate =>
298
+ {
299
+ // check name restriction, if any
300
+ if (allowedUpdate.DependencyName is not null)
301
+ {
302
+ var matcher = new Matcher(StringComparison.OrdinalIgnoreCase)
303
+ .AddInclude(allowedUpdate.DependencyName);
304
+ var result = matcher.Match(dependency.Name);
305
+ if (!result.HasMatches)
306
+ {
307
+ return false;
308
+ }
309
+ }
310
+
311
+ var isSecurityUpdate = allowedUpdate.UpdateType == UpdateType.Security || job.SecurityUpdatesOnly;
312
+ if (isSecurityUpdate)
313
+ {
314
+ // only update if it's vulnerable
315
+ return isVulnerable;
316
+ }
317
+ else
318
+ {
319
+ // not a security update, so only update if...
320
+ // ...we've been explicitly asked to update this
321
+ if ((job.Dependencies ?? []).Any(d => d.Equals(dependency.Name, StringComparison.OrdinalIgnoreCase)))
322
+ {
323
+ return true;
324
+ }
325
+
326
+ // ...no specific update being performed, do it if it's not transitive
327
+ return !dependency.IsTransitive;
328
+ }
329
+ });
330
+
331
+ return allowed;
332
+ }
333
+
292
334
  internal static ImmutableArray<Requirement> GetIgnoredRequirementsForDependency(Job job, string dependencyName)
293
335
  {
294
336
  var ignoreConditions = job.IgnoreConditions
@@ -375,7 +417,7 @@ public class RunWorker
375
417
  new ReportedDependency()
376
418
  {
377
419
  Name = d.Name,
378
- Requirements = d.IsTransitive ? [] : [new ReportedRequirement()
420
+ Requirements = [new ReportedRequirement()
379
421
  {
380
422
  File = GetFullRepoPath(p.FilePath),
381
423
  Requirement = d.Version!,
@@ -347,7 +347,7 @@ internal static class PackageReferenceUpdater
347
347
  projectDirectory,
348
348
  experimentsManager
349
349
  );
350
- MSBuildHelper.ThrowOnUnauthenticatedFeed(stdout);
350
+ MSBuildHelper.ThrowOnError(stdout);
351
351
  if (exitCode != 0)
352
352
  {
353
353
  logger.Warn($" Transitive dependency [{dependencyName}/{newDependencyVersion}] was not added.\nSTDOUT:\n{stdout}\nSTDERR:\n{stderr}");
@@ -148,18 +148,15 @@ internal static partial class PackagesConfigUpdater
148
148
 
149
149
  if (exitCodeAgain != 0)
150
150
  {
151
- MSBuildHelper.ThrowOnMissingFile(fullOutput);
152
- MSBuildHelper.ThrowOnMissingFile(restoreOutput);
153
- MSBuildHelper.ThrowOnMissingPackages(restoreOutput);
151
+ MSBuildHelper.ThrowOnError(fullOutput);
152
+ MSBuildHelper.ThrowOnError(restoreOutput);
154
153
  throw new Exception($"Unable to restore.\nOutput:\n${restoreOutput}\n");
155
154
  }
156
155
 
157
156
  goto doRestore;
158
157
  }
159
158
 
160
- MSBuildHelper.ThrowOnUnauthenticatedFeed(fullOutput);
161
- MSBuildHelper.ThrowOnMissingFile(fullOutput);
162
- MSBuildHelper.ThrowOnMissingPackages(fullOutput);
159
+ MSBuildHelper.ThrowOnError(fullOutput);
163
160
  throw new Exception(fullOutput);
164
161
  }
165
162
  }
@@ -903,21 +903,6 @@ internal static partial class MSBuildHelper
903
903
  }
904
904
  }
905
905
 
906
- internal static void ThrowOnUnauthenticatedFeed(string stdout)
907
- {
908
- var unauthorizedMessageSnippets = new string[]
909
- {
910
- "The plugin credential provider could not acquire credentials",
911
- "401 (Unauthorized)",
912
- "error NU1301: Unable to load the service index for source",
913
- "Response status code does not indicate success: 403",
914
- };
915
- if (unauthorizedMessageSnippets.Any(stdout.Contains))
916
- {
917
- throw new HttpRequestException(message: stdout, inner: null, statusCode: System.Net.HttpStatusCode.Unauthorized);
918
- }
919
- }
920
-
921
906
  internal static string? GetMissingFile(string output)
922
907
  {
923
908
  var missingFilePatterns = new[]
@@ -934,7 +919,30 @@ internal static partial class MSBuildHelper
934
919
  return null;
935
920
  }
936
921
 
937
- internal static void ThrowOnMissingFile(string output)
922
+ internal static void ThrowOnError(string output)
923
+ {
924
+ ThrowOnUnauthenticatedFeed(output);
925
+ ThrowOnMissingFile(output);
926
+ ThrowOnMissingPackages(output);
927
+ ThrowOnUpdateNotPossible(output);
928
+ }
929
+
930
+ private static void ThrowOnUnauthenticatedFeed(string stdout)
931
+ {
932
+ var unauthorizedMessageSnippets = new string[]
933
+ {
934
+ "The plugin credential provider could not acquire credentials",
935
+ "401 (Unauthorized)",
936
+ "error NU1301: Unable to load the service index for source",
937
+ "Response status code does not indicate success: 403",
938
+ };
939
+ if (unauthorizedMessageSnippets.Any(stdout.Contains))
940
+ {
941
+ throw new HttpRequestException(message: stdout, inner: null, statusCode: System.Net.HttpStatusCode.Unauthorized);
942
+ }
943
+ }
944
+
945
+ private static void ThrowOnMissingFile(string output)
938
946
  {
939
947
  var missingFile = GetMissingFile(output);
940
948
  if (missingFile is not null)
@@ -943,9 +951,9 @@ internal static partial class MSBuildHelper
943
951
  }
944
952
  }
945
953
 
946
- internal static void ThrowOnMissingPackages(string output)
954
+ private static void ThrowOnMissingPackages(string output)
947
955
  {
948
- var missingPackagesPattern = new Regex(@"Package '(?<PackageName>[^'].*)' is not found on source");
956
+ var missingPackagesPattern = new Regex(@"Package '(?<PackageName>[^']*)' is not found on source");
949
957
  var matchCollection = missingPackagesPattern.Matches(output);
950
958
  var missingPackages = matchCollection.Select(m => m.Groups["PackageName"].Value).Distinct().ToArray();
951
959
  if (missingPackages.Length > 0)
@@ -954,6 +962,23 @@ internal static partial class MSBuildHelper
954
962
  }
955
963
  }
956
964
 
965
+ private static void ThrowOnUpdateNotPossible(string output)
966
+ {
967
+ var patterns = new[]
968
+ {
969
+ new Regex(@"Unable to resolve dependencies\. '(?<PackageName>[^ ]+) (?<PackageVersion>[^']+)'"),
970
+ new Regex(@"Could not install package '(?<PackageName>[^ ]+) (?<PackageVersion>[^']+)'. You are trying to install this package"),
971
+ new Regex(@"Unable to find a version of '[^']+' that is compatible with '[^ ]+ [^ ]+ constraint: (?<PackageName>[^ ]+) \([^ ]+ (?<PackageVersion>[^)]+)\)'"),
972
+ new Regex(@"the following error\(s\) may be blocking the current package operation: '(?<PackageName>[^ ]+) (?<PackageVersion>[^ ]+) constraint:"),
973
+ };
974
+ var matches = patterns.Select(p => p.Match(output)).Where(m => m.Success);
975
+ if (matches.Any())
976
+ {
977
+ var packages = matches.Select(m => $"{m.Groups["PackageName"].Value}.{m.Groups["PackageVersion"].Value}").Distinct().ToArray();
978
+ throw new UpdateNotPossibleException(packages);
979
+ }
980
+ }
981
+
957
982
  internal static bool TryGetGlobalJsonPath(string repoRootPath, string workspacePath, [NotNullWhen(returnValue: true)] out string? globalJsonPath)
958
983
  {
959
984
  globalJsonPath = PathHelper.GetFileInDirectoryOrParent(workspacePath, repoRootPath, "global.json", caseSensitive: false);