Skip to content

Commit

Permalink
Stop on first failure if it's a dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
corbob committed Aug 14, 2024
1 parent 8dc0155 commit 37574fb
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/chocolatey/infrastructure.app/services/NugetService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,12 @@ Version was specified as '{0}'. It is possible that version
var nullResult = packageResultsToReturn.GetOrAdd(packageDependencyInfo.Id, x);
nullResult.Messages.Add(new ResultMessage(ResultType.Error, logMessage));
this.Log().Error(ChocolateyLoggers.Important, logMessage);

if (config.Features.StopOnFirstPackageFailure)
{
throw new ApplicationException("Stopping further execution as {0} has failed install.".FormatWith(packageDependencyInfo.Id));
}

continue;
}

Expand All @@ -833,6 +839,12 @@ Version was specified as '{0}'. It is possible that version
var nullResult = packageResultsToReturn.GetOrAdd(packageToUninstall.Name, packageToUninstall);
nullResult.Messages.Add(new ResultMessage(ResultType.Error, logMessage));
this.Log().Error(ChocolateyLoggers.Important, logMessage);

if (config.Features.StopOnFirstPackageFailure)
{
throw new ApplicationException("Stopping further execution as {0} has failed install.".FormatWith(packageToUninstall.Identity.Id));
}

continue;
}

Expand Down Expand Up @@ -1600,6 +1612,12 @@ public virtual ConcurrentDictionary<string, PackageResult> Upgrade(ChocolateyCon
var nullResult = packageResultsToReturn.GetOrAdd(packageDependencyInfo.Id, x);
nullResult.Messages.Add(new ResultMessage(ResultType.Error, logMessage));
this.Log().Error(ChocolateyLoggers.Important, logMessage);

if (config.Features.StopOnFirstPackageFailure)
{
throw new ApplicationException("Stopping further execution as {0} has failed.".FormatWith(packageDependencyInfo.Id));
}

continue;
}

Expand Down Expand Up @@ -1627,6 +1645,12 @@ public virtual ConcurrentDictionary<string, PackageResult> Upgrade(ChocolateyCon
var nullResult = packageResultsToReturn.GetOrAdd(packageToUninstall.Name, packageToUninstall);
nullResult.Messages.Add(new ResultMessage(ResultType.Error, logMessage));
this.Log().Error(ChocolateyLoggers.Important, logMessage);

if (config.Features.StopOnFirstPackageFailure)
{
throw new ApplicationException("Stopping further execution as {0} has failed.".FormatWith(packageDependencyInfo.Id));
}

continue;
}

Expand Down

0 comments on commit 37574fb

Please sign in to comment.