From 92111d1caa900fb324c0723a536925df20a64b73 Mon Sep 17 00:00:00 2001 From: ilia-shipitsin <125650415+ilia-shipitsin@users.noreply.github.com> Date: Tue, 10 Oct 2023 13:48:18 +0200 Subject: [PATCH] [windows] create powershell modules cache permanently (#8495) --- images/win/scripts/Installers/Configure-PowerShell.ps1 | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/images/win/scripts/Installers/Configure-PowerShell.ps1 b/images/win/scripts/Installers/Configure-PowerShell.ps1 index 98cb83055..32fdb0310 100644 --- a/images/win/scripts/Installers/Configure-PowerShell.ps1 +++ b/images/win/scripts/Installers/Configure-PowerShell.ps1 @@ -9,6 +9,15 @@ Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force # Specifies the installation policy Set-PSRepository -InstallationPolicy Trusted -Name PSGallery + +Write-Host 'Warmup PSModuleAnalysisCachePath (speedup first powershell invocation by 20s)' +$PSModuleAnalysisCachePath = 'C:\PSModuleAnalysisCachePath\ModuleAnalysisCache' + +[Environment]::SetEnvironmentVariable('PSModuleAnalysisCachePath', $PSModuleAnalysisCachePath, [System.EnvironmentVariableTarget]::Machine) +# make variable to be available in the current session +${env:PSModuleAnalysisCachePath} = $PSModuleAnalysisCachePath + +$null = New-Item -Path $PSModuleAnalysisCachePath -ItemType 'File' -Force #endregion #region User (current user, image generation only)