diff --git a/src/chocolatey/infrastructure.app/services/NugetService.cs b/src/chocolatey/infrastructure.app/services/NugetService.cs
index 651cd84e68..827016bf24 100644
--- a/src/chocolatey/infrastructure.app/services/NugetService.cs
+++ b/src/chocolatey/infrastructure.app/services/NugetService.cs
@@ -988,7 +988,21 @@ public virtual void remove_rollback_directory_if_exists(string packageName)
/// The original unmodified configuration, so it can be reset after upgrade
protected virtual ChocolateyConfiguration set_package_config_for_upgrade(ChocolateyConfiguration config, ChocolateyPackageInformation packageInfo)
{
- if (!config.Features.UseRememberedArgumentsForUpgrades || string.IsNullOrWhiteSpace(packageInfo.Arguments)) return config;
+ return set_package_config_from_remembered_args(config, packageInfo, CommandNameType.upgrade);
+ }
+
+ ///
+ /// Sets the configuration from remembered args
+ ///
+ /// The configuration.
+ /// The package information.
+ /// The command (like uninstall/upgrade) that is being run.
+ /// The original unmodified configuration, so it can be reset
+ protected virtual ChocolateyConfiguration set_package_config_from_remembered_args(ChocolateyConfiguration config, ChocolateyPackageInformation packageInfo, CommandNameType commandType)
+ {
+ if (string.IsNullOrWhiteSpace(packageInfo.Arguments)) return config;
+ if (commandType == CommandNameType.upgrade && !config.Features.UseRememberedArgumentsForUpgrades) return config;
+ if (commandType == CommandNameType.uninstall && !config.Features.UseRememberedArgumentsForUninstalls) return config;
var packageArgumentsUnencrypted = packageInfo.Arguments.contains(" --") && packageInfo.Arguments.to_string().Length > 4 ? packageInfo.Arguments : NugetEncryptionUtility.DecryptString(packageInfo.Arguments);
@@ -996,7 +1010,7 @@ protected virtual ChocolateyConfiguration set_package_config_for_upgrade(Chocola
if (!ArgumentsUtility.arguments_contain_sensitive_information(packageArgumentsUnencrypted))
{
sensitiveArgs = false;
- this.Log().Debug(ChocolateyLoggers.Verbose, "{0} - Adding remembered arguments for upgrade: {1}".format_with(packageInfo.Package.Id, packageArgumentsUnencrypted.escape_curly_braces()));
+ this.Log().Debug(ChocolateyLoggers.Verbose, "{0} - Adding remembered arguments: {1}".format_with(packageInfo.Package.Id, packageArgumentsUnencrypted.escape_curly_braces()));
}
var packageArgumentsSplit = packageArgumentsUnencrypted.Split(new[] { " --" }, StringSplitOptions.RemoveEmptyEntries);
@@ -1014,7 +1028,7 @@ protected virtual ChocolateyConfiguration set_package_config_for_upgrade(Chocola
if (sensitiveArgs)
{
- this.Log().Debug(ChocolateyLoggers.Verbose, "{0} - Adding '{1}' to upgrade arguments. Values not shown due to detected sensitive arguments".format_with(packageInfo.Package.Id, optionName.escape_curly_braces()));
+ this.Log().Debug(ChocolateyLoggers.Verbose, "{0} - Adding '{1}' to arguments. Values not shown due to detected sensitive arguments".format_with(packageInfo.Package.Id, optionName.escape_curly_braces()));
}
packageArguments.Add("--{0}{1}".format_with(optionName, string.IsNullOrWhiteSpace(optionValue) ? string.Empty : "=" + optionValue));
}