From 49df0c727f71f68dd7a7680b6d39c8557908309a Mon Sep 17 00:00:00 2001 From: TheCakeIsNaOH Date: Fri, 16 Apr 2021 21:12:30 -0500 Subject: [PATCH] (#2111) Deep copy config Always deep copy the config when making a backup originalConfig. This ensures that when the config is reset it gets fully reset. Fixes issues with reuse of arguments when useRememberedArgumentsForUpgrades is enabled. Also should fix #1443, not just #2111 --- .../infrastructure.app/services/NugetService.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/chocolatey/infrastructure.app/services/NugetService.cs b/src/chocolatey/infrastructure.app/services/NugetService.cs index 35ecc269ac..0a749a7c3b 100644 --- a/src/chocolatey/infrastructure.app/services/NugetService.cs +++ b/src/chocolatey/infrastructure.app/services/NugetService.cs @@ -435,7 +435,7 @@ public virtual ConcurrentDictionary install_run(Chocolate uninstallSuccessAction: null, addUninstallHandler: true); - var originalConfig = config; + var originalConfig = config.deep_copy(); foreach (string packageName in packageNames.or_empty_list_if_null()) { @@ -614,7 +614,7 @@ public virtual ConcurrentDictionary upgrade_run(Chocolate set_package_names_if_all_is_specified(config, () => { config.IgnoreDependencies = true; }); config.IgnoreDependencies = configIgnoreDependencies; - var originalConfig = config; + var originalConfig = config.deep_copy(); foreach (string packageName in config.PackageNames.Split(new[] { ApplicationParameters.PackageNamesSeparator }, StringSplitOptions.RemoveEmptyEntries).or_empty_list_if_null()) { @@ -890,7 +890,7 @@ public virtual ConcurrentDictionary get_outdated(Chocolat set_package_names_if_all_is_specified(config, () => { config.IgnoreDependencies = true; }); var packageNames = config.PackageNames.Split(new[] { ApplicationParameters.PackageNamesSeparator }, StringSplitOptions.RemoveEmptyEntries).or_empty_list_if_null().ToList(); - var originalConfig = config; + var originalConfig = config.deep_copy(); foreach (var packageName in packageNames) { @@ -1357,7 +1357,7 @@ public virtual ConcurrentDictionary uninstall_run(Chocola config.ForceDependencies = false; }); - var originalConfig = config; + var originalConfig = config.deep_copy(); foreach (string packageName in config.PackageNames.Split(new[] { ApplicationParameters.PackageNamesSeparator }, StringSplitOptions.RemoveEmptyEntries).or_empty_list_if_null()) {