mirror of
https://github.com/actions/runner-images.git
synced 2025-12-15 22:26:56 +00:00
[Windows][Improvement] Split and simplify "InitializeVM.ps1" script (#3806)
* improve InitializeVM script * Update windows2019.json * remove configs * resolve comments * resolve comments; fix order * fix templates
This commit is contained in:
32
images/win/scripts/Installers/Install-Choco.ps1
Normal file
32
images/win/scripts/Installers/Install-Choco.ps1
Normal file
@@ -0,0 +1,32 @@
|
||||
Write-Host "Set TLS1.2"
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor "Tls12"
|
||||
|
||||
Write-Host "Install chocolatey"
|
||||
$chocoExePath = 'C:\ProgramData\Chocolatey\bin'
|
||||
|
||||
# Add to system PATH
|
||||
$systemPath = [Environment]::GetEnvironmentVariable('Path', [System.EnvironmentVariableTarget]::Machine)
|
||||
$systemPath += ';' + $chocoExePath
|
||||
[Environment]::SetEnvironmentVariable("PATH", $systemPath, [System.EnvironmentVariableTarget]::Machine)
|
||||
|
||||
# Update local process' path
|
||||
$userPath = [Environment]::GetEnvironmentVariable('Path', [System.EnvironmentVariableTarget]::User)
|
||||
if ($userPath) {
|
||||
$env:Path = $systemPath + ";" + $userPath
|
||||
} else {
|
||||
$env:Path = $systemPath
|
||||
}
|
||||
|
||||
# Run the installer
|
||||
Invoke-Expression ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))
|
||||
|
||||
# Turn off confirmation
|
||||
choco feature enable -n allowGlobalConfirmation
|
||||
|
||||
# https://github.com/chocolatey/choco/issues/89
|
||||
# Remove some of the command aliases, like `cpack` #89
|
||||
Remove-Item -Path $env:ChocolateyInstall\bin\cpack.exe -Force
|
||||
|
||||
# Initialize environmental variable ChocolateyToolsLocation by invoking choco Get-ToolsLocation function
|
||||
Import-Module "$env:ChocolateyInstall\helpers\chocolateyInstaller.psm1" -Force
|
||||
Get-ToolsLocation
|
||||
Reference in New Issue
Block a user