diff --git a/src/chocolatey.resources/helpers/ChocolateyTabExpansion.ps1 b/src/chocolatey.resources/helpers/ChocolateyTabExpansion.ps1 index 2eb13a8341..00541b4028 100644 --- a/src/chocolatey.resources/helpers/ChocolateyTabExpansion.ps1 +++ b/src/chocolatey.resources/helpers/ChocolateyTabExpansion.ps1 @@ -47,7 +47,7 @@ $commandOptions = @{ install = "-y -whatif --pre --version= --params='' --install-arguments='' --override-arguments --ignore-dependencies --source='' --source='windowsfeatures' --user='' --password='' --prerelease --forcex86 --not-silent --package-parameters='' --exit-when-reboot-detected --ignore-detected-reboot --allow-downgrade --force-dependencies --require-checksums --use-package-exit-codes --ignore-package-exit-codes --skip-automation-scripts --ignore-checksums --allow-empty-checksums --allow-empty-checksums-secure --download-checksum='' --download-checksum-type='' --download-checksum-x64='' --download-checksum-type-x64='' --stop-on-first-package-failure --disable-package-repository-optimizations --pin" pin = "--name='' --version=''" outdated = "--source='' --user='' --password='' --ignore-pinned --ignore-unfound --pre --prerelease --disable-package-repository-optimizations" - upgrade = "-y -whatif --pre --version='' --except='' --params='' --install-arguments='' --override-arguments --ignore-dependencies --source='' --source='windowsfeatures' --user='' --password='' --prerelease --forcex86 --not-silent --package-parameters='' --exit-when-reboot-detected --ignore-detected-reboot --allow-downgrade --require-checksums --use-package-exit-codes --ignore-package-exit-codes --skip-automation-scripts --fail-on-unfound --fail-on-not-installed --ignore-checksums --allow-empty-checksums --allow-empty-checksums-secure --download-checksum='' --download-checksum-type='' --download-checksum-x64='' --download-checksum-type-x64='' --exclude-prerelease --stop-on-first-package-failure --use-remembered-options --ignore-remembered-options --skip-when-not-installed --install-if-not-installed --disable-package-repository-optimizations --pin" + upgrade = "-y -whatif --pre --version='' --except='' --params='' --install-arguments='' --override-arguments --ignore-dependencies --source='' --source='windowsfeatures' --user='' --password='' --prerelease --forcex86 --not-silent --package-parameters='' --exit-when-reboot-detected --ignore-detected-reboot --allow-downgrade --require-checksums --use-package-exit-codes --ignore-package-exit-codes --skip-automation-scripts --fail-on-unfound --fail-on-not-installed --ignore-checksums --allow-empty-checksums --allow-empty-checksums-secure --download-checksum='' --download-checksum-type='' --download-checksum-x64='' --download-checksum-type-x64='' --exclude-prerelease --stop-on-first-package-failure --use-remembered-options --ignore-remembered-options --skip-when-not-installed --install-if-not-installed --disable-package-repository-optimizations --pin --ignore-pinned" uninstall = "-y -whatif --force-dependencies --remove-dependencies --all-versions --source='windowsfeatures' --version= --uninstall-arguments='' --override-arguments --not-silent --params='' --package-parameters='' --exit-when-reboot-detected --ignore-detected-reboot --use-package-exit-codes --ignore-package-exit-codes --skip-automation-scripts --use-autouninstaller --skip-autouninstaller --fail-on-autouninstaller --ignore-autouninstaller-failure --stop-on-first-package-failure" new = "--template-name='' --output-directory='' --automaticpackage --version='' --maintainer='' packageversion='' maintainername='' maintainerrepo='' installertype='' url='' url64='' silentargs='' --use-built-in-template" pack = "--version='' --output-directory=''" diff --git a/src/chocolatey/infrastructure.app/commands/ChocolateyUpgradeCommand.cs b/src/chocolatey/infrastructure.app/commands/ChocolateyUpgradeCommand.cs index c7b6e94b56..3413580c7d 100644 --- a/src/chocolatey/infrastructure.app/commands/ChocolateyUpgradeCommand.cs +++ b/src/chocolatey/infrastructure.app/commands/ChocolateyUpgradeCommand.cs @@ -250,6 +250,10 @@ public virtual void ConfigureArgumentParser(OptionSet optionSet, ChocolateyConfi "Skip hooks - Do not run hook scripts. Available in 1.2.0+", option => configuration.SkipHookScripts = option != null ) + .Add("ignore-pinned", + "Ignore Pinned - Ignores any pins and upgrades the package(s) anyway. Available in 2.3.0+", + option => configuration.UpgradeCommand.IgnorePinned = option != null + ) ; } diff --git a/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs b/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs index 426fa92288..b7d19ee396 100644 --- a/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs +++ b/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs @@ -600,6 +600,7 @@ public sealed class UpgradeCommandConfiguration public bool NotifyOnlyAvailableUpgrades { get; set; } public string PackageNamesToSkip { get; set; } public bool ExcludePrerelease { get; set; } + public bool IgnorePinned { get; set; } } [Serializable] diff --git a/src/chocolatey/infrastructure.app/services/NugetService.cs b/src/chocolatey/infrastructure.app/services/NugetService.cs index 3184a614f5..b396ccb26e 100644 --- a/src/chocolatey/infrastructure.app/services/NugetService.cs +++ b/src/chocolatey/infrastructure.app/services/NugetService.cs @@ -1108,7 +1108,7 @@ public virtual ConcurrentDictionary Upgrade(ChocolateyCon var pkgInfo = _packageInfoService.Get(installedPackage.PackageMetadata); var isPinned = pkgInfo != null && pkgInfo.IsPinned; - if (isPinned && config.OutdatedCommand.IgnorePinned) + if (isPinned && config.OutdatedCommand.IgnorePinned && !config.UpgradeCommand.IgnorePinned) { continue; } @@ -1246,15 +1246,31 @@ public virtual ConcurrentDictionary Upgrade(ChocolateyCon if (isPinned) { - var logMessage = "{0} is pinned. Skipping pinned package.".FormatWith(packageName); - packageResult.Messages.Add(new ResultMessage(ResultType.Warn, logMessage)); - packageResult.Messages.Add(new ResultMessage(ResultType.Inconclusive, logMessage)); - if (config.RegularOutput) + if (!config.UpgradeCommand.IgnorePinned) { - this.Log().Warn(ChocolateyLoggers.Important, logMessage); + var logMessage = "{0} is pinned. Skipping pinned package.".FormatWith(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; } + else + { + var logMessage = "{0} is pinned. Upgrading pinned package anyway as ignore pin is specified".FormatWith(packageName); + packageResult.Messages.Add(new ResultMessage(ResultType.Warn, logMessage)); - continue; + if (config.RegularOutput) + { + this.Log().Warn(ChocolateyLoggers.Important, logMessage); + } + + config.PinPackage = true; + } } if (performAction) @@ -1326,7 +1342,12 @@ public virtual ConcurrentDictionary Upgrade(ChocolateyCon } } - var removedSources = RemovePinnedSourceDependencies(sourcePackageDependencyInfos, allLocalPackages); + var removedSources = new HashSet(); + + if (!config.UpgradeCommand.IgnorePinned) + { + RemovePinnedSourceDependencies(sourcePackageDependencyInfos, allLocalPackages); + } if (version != null || removedSources.Count == 0) {