diff --git a/src/chocolatey/infrastructure.app/services/NugetService.cs b/src/chocolatey/infrastructure.app/services/NugetService.cs index 127d50de44..03ed7e4fb6 100644 --- a/src/chocolatey/infrastructure.app/services/NugetService.cs +++ b/src/chocolatey/infrastructure.app/services/NugetService.cs @@ -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; } @@ -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; } @@ -1600,6 +1612,12 @@ public virtual ConcurrentDictionary 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; } @@ -1627,6 +1645,12 @@ public virtual ConcurrentDictionary 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; }