diff --git a/src/chocolatey/infrastructure.app/commands/ChocolateyUpgradeCommand.cs b/src/chocolatey/infrastructure.app/commands/ChocolateyUpgradeCommand.cs index a45ca6e615..0caa6aa2bf 100644 --- a/src/chocolatey/infrastructure.app/commands/ChocolateyUpgradeCommand.cs +++ b/src/chocolatey/infrastructure.app/commands/ChocolateyUpgradeCommand.cs @@ -165,7 +165,7 @@ public virtual void configure_argument_parser(OptionSet optionSet, ChocolateyCon .Add("stoponfirstfailure|stop-on-first-failure|stop-on-first-package-failure", "Stop On First Package Failure - stop running install, upgrade or uninstall on first package failure instead of continuing with others. Overrides the default feature '{0}' set to '{1}'. Available in 0.10.4+.".format_with(ApplicationParameters.Features.StopOnFirstPackageFailure, configuration.Features.StopOnFirstPackageFailure.to_string()), option => configuration.Features.StopOnFirstPackageFailure = option != null - ) + ) .Add("skip-if-not-installed|only-upgrade-installed|skip-when-not-installed", "Skip Packages Not Installed - if a package is not installed, do not install it during the upgrade process. Overrides the default feature '{0}' set to '{1}'. Available in 0.10.12+.".format_with(ApplicationParameters.Features.SkipPackageUpgradesWhenNotInstalled, configuration.Features.SkipPackageUpgradesWhenNotInstalled.to_string()), option => configuration.Features.SkipPackageUpgradesWhenNotInstalled = option != null @@ -224,6 +224,9 @@ public virtual void configure_argument_parser(OptionSet optionSet, ChocolateyCon "Pin Package - Add a pin to the package after upgrade. Available in 0.11.12+", option => configuration.PinPackage = option != null ) + .Add("bypass-pins|ignore-pins", + "Bypass Pin(s) - Bypass any pins and upgrade the packages anyways. Defaults to false. Available in 1.0.0+", + option => configuration.UpgradeCommand.BypassPins = option != null) ; } @@ -307,7 +310,7 @@ choco upgrade notepadplusplus googlechrome atom 7zip -dvfy choco upgrade git -y --params=""'/GitAndUnixToolsOnPath /NoAutoCrlf'"" choco upgrade git -y --params=""'/GitAndUnixToolsOnPath /NoAutoCrlf'"" --install-args=""'/DIR=C:\git'"" # Params are package parameters, passed to the package - # Install args are installer arguments, appended to the silentArgs + # Install args are installer arguments, appended to the silentArgs # in the package for the installer itself choco upgrade nodejs.install --version 0.10.35 choco upgrade git -s ""'https://somewhere/out/there'"" @@ -315,7 +318,7 @@ choco upgrade nodejs.install --version 0.10.35 choco upgrade all choco upgrade all --except=""'skype,conemu'"" -NOTE: See scripting in the command reference (`choco -?`) for how to +NOTE: See scripting in the command reference (`choco -?`) for how to write proper scripts and integrations. "); @@ -347,7 +350,7 @@ when the feature '{1}' is turned on. It typically requires the feature '{0}' to also be turned on to work properly. Available in v0.10.12+. ".format_with(ApplicationParameters.Features.UsePackageExitCodes, ApplicationParameters.Features.ExitOnRebootDetected)); - + "chocolatey".Log().Info(ChocolateyLoggers.Important, "See It In Action"); "chocolatey".Log().Info(@" choco upgrade: https://raw.githubusercontent.com/wiki/chocolatey/choco/images/gifs/choco_upgrade.gif diff --git a/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs b/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs index 97cabfc2ca..8de2786e0d 100644 --- a/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs +++ b/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs @@ -450,6 +450,7 @@ public sealed class UpgradeCommandConfiguration public bool NotifyOnlyAvailableUpgrades { get; set; } public string PackageNamesToSkip { get; set; } public bool ExcludePrerelease { get; set; } + public bool BypassPins { get; set; } } [Serializable] diff --git a/src/chocolatey/infrastructure.app/services/NugetService.cs b/src/chocolatey/infrastructure.app/services/NugetService.cs index ca285817bb..3d426d94f4 100644 --- a/src/chocolatey/infrastructure.app/services/NugetService.cs +++ b/src/chocolatey/infrastructure.app/services/NugetService.cs @@ -680,7 +680,7 @@ public virtual ConcurrentDictionary upgrade_run(Chocolate var pkgInfo = _packageInfoService.get_package_information(installedPackage); bool isPinned = pkgInfo != null && pkgInfo.IsPinned; - if (isPinned && config.OutdatedCommand.IgnorePinned) + if (isPinned && config.OutdatedCommand.IgnorePinned && !config.UpgradeCommand.BypassPins) { continue; } @@ -812,12 +812,25 @@ public virtual ConcurrentDictionary upgrade_run(Chocolate if (isPinned) { - string logMessage = "{0} is pinned. Skipping pinned package.".format_with(packageName); - packageResult.Messages.Add(new ResultMessage(ResultType.Warn, logMessage)); - packageResult.Messages.Add(new ResultMessage(ResultType.Inconclusive, logMessage)); - if (config.RegularOutput) this.Log().Warn(ChocolateyLoggers.Important, logMessage); + if (!config.UpgradeCommand.BypassPins) + { + string logMessage = "{0} is pinned. Skipping pinned package.".format_with(packageName); + packageResult.Messages.Add(new ResultMessage(ResultType.Warn, logMessage)); + packageResult.Messages.Add(new ResultMessage(ResultType.Inconclusive, logMessage)); + if (config.RegularOutput) this.Log().Warn(ChocolateyLoggers.Important, logMessage); - continue; + continue; + } + else + { + string logMessage = "{0} is pinned. Upgrading pinned package anyway as bypass-pins is specified".format_with(packageName); + packageResult.Messages.Add(new ResultMessage(ResultType.Warn, logMessage)); + if (config.RegularOutput) this.Log().Warn(ChocolateyLoggers.Important, logMessage); + config.PinPackage = true; + + //Reset the config in ChocolateyPackageService in so the package will be re-pinned after install + resetConfigAction(config); + } } set_package_config_for_upgrade(config, pkgInfo);