diff --git a/src/chocolatey.tests/infrastructure.app/commands/ChocolateyOutdatedCommandSpecs.cs b/src/chocolatey.tests/infrastructure.app/commands/ChocolateyOutdatedCommandSpecs.cs index 59dd99d5f4..49cfaf8f5d 100644 --- a/src/chocolatey.tests/infrastructure.app/commands/ChocolateyOutdatedCommandSpecs.cs +++ b/src/chocolatey.tests/infrastructure.app/commands/ChocolateyOutdatedCommandSpecs.cs @@ -108,7 +108,18 @@ public void should_add_short_version_of_password_to_the_option_set() { optionSet.Contains("p").ShouldBeTrue(); } - + + [Fact] + public void should_add_ignore_pinned_to_the_option_set() + { + optionSet.Contains("ignore-pinned").ShouldBeTrue(); + } + + [Fact] + public void should_add_short_version_of_ignore_pinned_to_the_option_set() + { + optionSet.Contains("ip").ShouldBeTrue(); + } } public class when_noop_is_called : ChocolateyOutdatedCommandSpecsBase diff --git a/src/chocolatey/infrastructure.app/commands/ChocolateyOutdatedCommand.cs b/src/chocolatey/infrastructure.app/commands/ChocolateyOutdatedCommand.cs index 7c9cbe6d81..09fef36db0 100644 --- a/src/chocolatey/infrastructure.app/commands/ChocolateyOutdatedCommand.cs +++ b/src/chocolatey/infrastructure.app/commands/ChocolateyOutdatedCommand.cs @@ -50,7 +50,10 @@ public virtual void configure_argument_parser(OptionSet optionSet, ChocolateyCon option => configuration.SourceCommand.Certificate = option.remove_surrounding_quotes()) .Add("cp=|certpassword=", "Certificate Password - the client certificate's password to the source. Defaults to empty. Available in 0.9.10+.", - option => configuration.SourceCommand.CertificatePassword = option.remove_surrounding_quotes()) + option => configuration.SourceCommand.CertificatePassword = option.remove_surrounding_quotes()) + .Add("ip|ignore-pinned", + "IgnorePinned - Ignore pinned packages. Defaults to false.", + option => configuration.OutdatedCommand.IgnorePinned = option != null) ; } diff --git a/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs b/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs index 0af28bc32d..3b1f5538b9 100644 --- a/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs +++ b/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs @@ -19,6 +19,7 @@ namespace chocolatey.infrastructure.app.configuration using System.Collections.Generic; using System.Reflection; using System.Text; + using commands; using domain; using logging; using platforms; @@ -46,7 +47,8 @@ public ChocolateyConfiguration() ApiKeyCommand = new ApiKeyCommandConfiguration(); PushCommand = new PushCommandConfiguration(); PinCommand = new PinCommandConfiguration(); - Proxy = new ProxyConfiguration(); + OutdatedCommand = new OutdatedCommandConfiguration(); + Proxy = new ProxyConfiguration(); #if DEBUG AllowUnofficialBuild = true; #endif @@ -111,7 +113,7 @@ private void output_tostring(StringBuilder propertyValues, IEnumerable /// On .NET 4.0, get error CS0200 when private set - see http://stackoverflow.com/a/23809226/18475 /// - public PinCommandConfiguration PinCommand { get; set; } - + public PinCommandConfiguration PinCommand { get; set; } + + /// + /// Configuration related specifically to Outdated command + /// + /// + /// On .NET 4.0, get error CS0200 when private set - see http://stackoverflow.com/a/23809226/18475 + /// + public OutdatedCommandConfiguration OutdatedCommand { get; set; } + /// /// Configuration related specifically to proxies. /// @@ -452,6 +462,12 @@ public sealed class PinCommandConfiguration public PinCommandType Command { get; set; } } + [Serializable] + public sealed class OutdatedCommandConfiguration + { + public bool IgnorePinned { get; set; } + } + [Serializable] public sealed class ApiKeyCommandConfiguration { diff --git a/src/chocolatey/infrastructure.app/services/NugetService.cs b/src/chocolatey/infrastructure.app/services/NugetService.cs index fc3b59e7bb..803f487fc9 100644 --- a/src/chocolatey/infrastructure.app/services/NugetService.cs +++ b/src/chocolatey/infrastructure.app/services/NugetService.cs @@ -578,6 +578,14 @@ public ConcurrentDictionary upgrade_run(ChocolateyConfigu continue; } + var pkgInfo = _packageInfoService.get_package_information(installedPackage); + bool isPinned = pkgInfo != null && pkgInfo.IsPinned; + + if (isPinned && config.OutdatedCommand.IgnorePinned) + { + continue; + } + if (version != null && version < installedPackage.Version && !config.AllowMultipleVersions && !config.AllowDowngrade) { string logMessage = "A newer version of {0} (v{1}) is already installed.{2} Use --allow-downgrade or --force to attempt to upgrade to older versions, or use side by side to allow multiple versions.".format_with(installedPackage.Id, installedPackage.Version, Environment.NewLine); @@ -585,11 +593,7 @@ public ConcurrentDictionary upgrade_run(ChocolateyConfigu nullResult.Messages.Add(new ResultMessage(ResultType.Error, logMessage)); this.Log().Error(ChocolateyLoggers.Important, logMessage); continue; - } - - var pkgInfo = _packageInfoService.get_package_information(installedPackage); - bool isPinned = pkgInfo != null && pkgInfo.IsPinned; - + } IPackage availablePackage = packageManager.SourceRepository.FindPackage(packageName, version, config.Prerelease, allowUnlisted: false); if (availablePackage == null)