From 77dfce0ba3ec0ba5c8a8d49520045c2fc104a0bc Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Fri, 17 Feb 2023 23:23:48 +0200 Subject: [PATCH] Use and clear a local nuget cache (#13256) * Use and clear a local nuget cache * more --- eng/cake/dotnet.cake | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/eng/cake/dotnet.cake b/eng/cake/dotnet.cake index 630842987ba3..d78ddde04143 100644 --- a/eng/cake/dotnet.cake +++ b/eng/cake/dotnet.cake @@ -490,6 +490,8 @@ Task("VS") Error("!!!!BUILD TASKS FAILED: !!!!!"); } + UseLocalNuGetCacheFolder(); + StartVisualStudioForDotNet6(); }); @@ -568,6 +570,23 @@ void SetDotNetEnvironmentVariables() SetEnvironmentVariable("MSBuildDebugEngine", "1"); } +void UseLocalNuGetCacheFolder(bool reset = false) +{ + var temp = Context.Environment.GetSpecialPath(SpecialPath.LocalTemp); + var packages = temp.Combine("Microsoft.Maui.Cache/NuGet/packages"); + + EnsureDirectoryExists(packages); + + CleanDirectories(packages.FullPath + "/microsoft.maui.*"); + CleanDirectories(packages.FullPath + "/microsoft.aspnetcore.*"); + + if (reset) + CleanDirectories(packages.FullPath); + + SetEnvironmentVariable("RestorePackagesPath", packages.FullPath); + SetEnvironmentVariable("NUGET_PACKAGES", packages.FullPath); +} + void StartVisualStudioForDotNet6() { string sln = Argument("sln", null);