diff --git a/src/chocolatey/infrastructure.app/runners/GenericRunner.cs b/src/chocolatey/infrastructure.app/runners/GenericRunner.cs
index d6853a53df..7a0d9c84f4 100644
--- a/src/chocolatey/infrastructure.app/runners/GenericRunner.cs
+++ b/src/chocolatey/infrastructure.app/runners/GenericRunner.cs
@@ -19,6 +19,7 @@ namespace chocolatey.infrastructure.app.runners
using System;
using System.Linq;
using System.Collections.Generic;
+ using filesystem;
using SimpleInjector;
using adapters;
using attributes;
@@ -139,6 +140,28 @@ public void run(ChocolateyConfiguration config, Container container, bool isCons
this.Log().Debug("_ {0}:{1} - Normal Run Mode _".format_with(ApplicationParameters.Name, command.GetType().Name));
command.run(config);
}
+
+ remove_nuget_cache(container);
+ }
+
+ ///
+ /// if there is a NuGetScratch cache found, kill it with fire
+ ///
+ /// The container.
+ private void remove_nuget_cache(Container container)
+ {
+ try
+ {
+ var fileSystem = container.GetInstance();
+ var scratch = fileSystem.combine_paths(fileSystem.get_temp_path(), "NuGetScratch");
+ fileSystem.delete_directory_if_exists(scratch, recursive: true, overrideAttributes: true, isSilent: true);
+ var nugetX = fileSystem.combine_paths(fileSystem.get_temp_path(), "x", "nuget");
+ fileSystem.delete_directory_if_exists(nugetX, recursive: true, overrideAttributes: true, isSilent: true);
+ }
+ catch (Exception ex)
+ {
+ this.Log().Debug(ChocolateyLoggers.Important, "Not able to cleanup NuGet temp folders. Failure was {0}".format_with(ex.Message));
+ }
}
public IEnumerable list(ChocolateyConfiguration config, Container container, bool isConsole, Action parseArgs)