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);