Skip to content

Commit e988612

Browse files
[windows] create powershell modules cache permanently
PSModuleAnalysisCachePath points to modules analysis cache. By default it is stored in user profile. We create user every time, and module analysis cache rebuild takes ~20s. by storing cache in permanent location, initial powershell startup takes ~8s instead of ~20s
1 parent 23ff0d7 commit e988612

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

images/win/scripts/Installers/Configure-PowerShell.ps1

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@ Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
99

1010
# Specifies the installation policy
1111
Set-PSRepository -InstallationPolicy Trusted -Name PSGallery
12+
13+
Write-Host 'Warmup PSModuleAnalysisCachePath (speedup first powershell invocation by 20s)'
14+
$PSModuleAnalysisCachePath = 'C:\PSModuleAnalysisCachePath\ModuleAnalysisCache'
15+
16+
[Environment]::SetEnvironmentVariable('PSModuleAnalysisCachePath', $PSModuleAnalysisCachePath, [System.EnvironmentVariableTarget]::Machine)
17+
# make variable to be available in the current session
18+
${env:PSModuleAnalysisCachePath} = $PSModuleAnalysisCachePath
19+
20+
$null = New-Item -Path $PSModuleAnalysisCachePath -ItemType 'File' -Force
1221
#endregion
1322

1423
#region User (current user, image generation only)

0 commit comments

Comments
 (0)