Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[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
  • Loading branch information
ilia-shipitsin committed Oct 9, 2023
commit e98861277a11311d18657a50464553d49bb45d40
9 changes: 9 additions & 0 deletions images/win/scripts/Installers/Configure-PowerShell.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down