From 88d5fb0e4b2a9644393048489f6c2474a848b607 Mon Sep 17 00:00:00 2001 From: Cory Knox Date: Thu, 25 Aug 2022 16:34:50 -0700 Subject: [PATCH] (#933) Re-use chocolatey that we already have We can't just tell it not to append the logger. If we do that, we cause a regression of 697. But we can use the instance we already have, and just backup and restore the config. --- .../Services/ChocolateyService.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Source/ChocolateyGui.Common.Windows/Services/ChocolateyService.cs b/Source/ChocolateyGui.Common.Windows/Services/ChocolateyService.cs index 9af4dc93d..cef18b377 100644 --- a/Source/ChocolateyGui.Common.Windows/Services/ChocolateyService.cs +++ b/Source/ChocolateyGui.Common.Windows/Services/ChocolateyService.cs @@ -172,8 +172,8 @@ public async Task InstallPackage( using (await Lock.WriteLockAsync()) { var logger = new SerilogLogger(Logger, _progressService); - var choco = Lets.GetChocolatey(initializeLogging: false).SetCustomLogging(logger, logExistingMessages: false, addToExistingLoggers: false); - choco.Set( + var currentConfig = _choco.GetConfiguration(); + _choco.Set( config => { config.CommandName = CommandNameType.install.ToString(); @@ -244,7 +244,7 @@ public async Task InstallPackage( using (logger.Intercept(grabErrors)) { - await choco.RunAsync(); + await _choco.RunAsync(); if (Environment.ExitCode != 0) { @@ -252,6 +252,10 @@ public async Task InstallPackage( return new PackageOperationResult { Successful = false, Messages = errors.ToArray() }; } + _choco.Set(config => + { + config = currentConfig; + }); return PackageOperationResult.SuccessfulCached; } }