From 6df32976d3ea39823981da70581bfae782f4eefc Mon Sep 17 00:00:00 2001 From: Christian Rondeau Date: Sat, 27 Jun 2015 12:07:21 -0400 Subject: [PATCH] (GH-293) Upgrade all except simple implementation --- .../commands/ChocolateyUpgradeCommand.cs | 3 +++ .../configuration/ChocolateyConfiguration.cs | 1 + .../infrastructure.app/services/NugetService.cs | 14 +++++++++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/chocolatey/infrastructure.app/commands/ChocolateyUpgradeCommand.cs b/src/chocolatey/infrastructure.app/commands/ChocolateyUpgradeCommand.cs index a5b0763faf..d6f12ee229 100644 --- a/src/chocolatey/infrastructure.app/commands/ChocolateyUpgradeCommand.cs +++ b/src/chocolatey/infrastructure.app/commands/ChocolateyUpgradeCommand.cs @@ -85,6 +85,9 @@ public virtual void configure_argument_parser(OptionSet optionSet, ChocolateyCon .Add("p=|password=", "Password - the user's password to the source. Defaults to empty.", option => configuration.SourceCommand.Password = option.remove_surrounding_quotes()) + .Add("except=", + "Except - a comma-separated list of package names that should not be upgraded. Defaults to empty.", + option => configuration.UpgradeCommand.PackageNamesToSkip = option.remove_surrounding_quotes()) ; } diff --git a/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs b/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs index 3720f48c74..eb9cd24d64 100644 --- a/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs +++ b/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs @@ -318,6 +318,7 @@ public sealed class UpgradeCommandConfiguration public bool FailOnUnfound { get; set; } public bool FailOnNotInstalled { get; set; } public bool NotifyOnlyAvailableUpgrades { get; set; } + public string PackageNamesToSkip { get; set; } } [Serializable] diff --git a/src/chocolatey/infrastructure.app/services/NugetService.cs b/src/chocolatey/infrastructure.app/services/NugetService.cs index 55e19a16fb..05876d6e1e 100644 --- a/src/chocolatey/infrastructure.app/services/NugetService.cs +++ b/src/chocolatey/infrastructure.app/services/NugetService.cs @@ -1045,12 +1045,24 @@ private void set_package_names_if_all_is_specified(ChocolateyConfiguration confi config.Input = string.Empty; var localPackages = list_run(config, logResults: false); + var packagesToUpdate = localPackages.Select((p) => p.Key); + + if (!String.IsNullOrEmpty(config.UpgradeCommand.PackageNamesToSkip)) + { + var packagesToSkip = config.UpgradeCommand.PackageNamesToSkip + .Split(',') + .Select(x => x.Trim()) + .Where(x => !String.IsNullOrEmpty(x)); + + packagesToUpdate = packagesToUpdate.Where(x => !packagesToSkip.Contains(x, StringComparer.OrdinalIgnoreCase)); + } config.Input = input; config.Noop = noop; config.Prerelease = pre; config.Sources = sources; - config.PackageNames = string.Join(ApplicationParameters.PackageNamesSeparator, localPackages.Select((p) => p.Key).or_empty_list_if_null()); + + config.PackageNames = string.Join(ApplicationParameters.PackageNamesSeparator, packagesToUpdate); if (customAction != null) customAction.Invoke(); }