mirror of
https://github.com/actions/runner-images.git
synced 2026-01-06 18:19:54 +08:00
Merge branch 'main' into lg/postgres-win-update
This commit is contained in:
@@ -3,12 +3,6 @@
|
||||
## Desc: Applies various configuration settings to the final image
|
||||
################################################################################
|
||||
|
||||
Write-Host "Cleanup WinSxS"
|
||||
dism.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Failed to cleanup WinSxS"
|
||||
}
|
||||
|
||||
# Set default version to 1 for WSL (aka LXSS - Linux Subsystem)
|
||||
# The value should be set in the default user registry hive
|
||||
# https://github.com/actions/runner-images/issues/5760
|
||||
@@ -31,53 +25,10 @@ if (Test-IsWin22) {
|
||||
$key.SetValue("DefaultVersion", "1", "DWord")
|
||||
$key.Handle.Close()
|
||||
[System.GC]::Collect()
|
||||
|
||||
|
||||
Dismount-RegistryHive "HKLM\DEFAULT"
|
||||
}
|
||||
|
||||
Write-Host "Clean up various directories"
|
||||
@(
|
||||
"$env:SystemDrive\Recovery",
|
||||
"$env:SystemRoot\logs",
|
||||
"$env:SystemRoot\winsxs\manifestcache",
|
||||
"$env:SystemRoot\Temp",
|
||||
"$env:SystemDrive\Users\$env:INSTALL_USER\AppData\Local\Temp",
|
||||
"$env:TEMP",
|
||||
"$env:AZURE_CONFIG_DIR\logs",
|
||||
"$env:AZURE_CONFIG_DIR\commands",
|
||||
"$env:AZURE_CONFIG_DIR\telemetry"
|
||||
) | ForEach-Object {
|
||||
if (Test-Path $_) {
|
||||
Write-Host "Removing $_"
|
||||
cmd /c "takeown /d Y /R /f $_ 2>&1" | Out-Null
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Failed to take ownership of $_"
|
||||
}
|
||||
cmd /c "icacls $_ /grant:r administrators:f /t /c /q 2>&1" | Out-Null
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Failed to grant administrators full control of $_"
|
||||
}
|
||||
Remove-Item $_ -Recurse -Force -ErrorAction SilentlyContinue | Out-Null
|
||||
}
|
||||
}
|
||||
|
||||
$winInstallDir = "$env:SystemRoot\Installer"
|
||||
New-Item -Path $winInstallDir -ItemType Directory -Force | Out-Null
|
||||
|
||||
# Remove AllUsersAllHosts profile
|
||||
Remove-Item $profile.AllUsersAllHosts -Force -ErrorAction SilentlyContinue | Out-Null
|
||||
|
||||
# Clean yarn and npm cache
|
||||
cmd /c "yarn cache clean 2>&1" | Out-Null
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Failed to clean yarn cache"
|
||||
}
|
||||
|
||||
cmd /c "npm cache clean --force 2>&1" | Out-Null
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Failed to clean npm cache"
|
||||
}
|
||||
|
||||
# allow msi to write to temp folder
|
||||
# see https://github.com/actions/runner-images/issues/1704
|
||||
cmd /c "icacls $env:SystemRoot\Temp /grant Users:f /t /c /q 2>&1" | Out-Null
|
||||
|
||||
@@ -9,7 +9,7 @@ $signatureThumbprint = "8740DF4ACB749640AD318E4BE842F72EC651AD80"
|
||||
Write-Host "Downloading BizTalk Project Build Component archive..."
|
||||
$zipFile = Invoke-DownloadWithRetry $downloadUrl
|
||||
|
||||
$setupPath = Join-Path $env:TEMP "BizTalkBuildComponent"
|
||||
$setupPath = Join-Path $env:TEMP_DIR "BizTalkBuildComponent"
|
||||
if (-not (Test-Path -Path $setupPath)) {
|
||||
New-Item -Path $setupPath -ItemType Directory -Force | Out-Null
|
||||
}
|
||||
|
||||
@@ -23,9 +23,9 @@ $mobyReleaseUrl = $dockerceUrl + $mobyRelease
|
||||
|
||||
Write-Host "Install Moby $mobyRelease..."
|
||||
$mobyArchivePath = Invoke-DownloadWithRetry $mobyReleaseUrl
|
||||
Expand-Archive -Path $mobyArchivePath -DestinationPath $env:TEMP
|
||||
$dockerPath = "$env:TEMP\docker\docker.exe"
|
||||
$dockerdPath = "$env:TEMP\docker\dockerd.exe"
|
||||
Expand-Archive -Path $mobyArchivePath -DestinationPath $env:TEMP_DIR
|
||||
$dockerPath = "$env:TEMP_DIR\docker\docker.exe"
|
||||
$dockerdPath = "$env:TEMP_DIR\docker\dockerd.exe"
|
||||
|
||||
Write-Host "Install Docker CE"
|
||||
$instScriptUrl = "https://raw.githubusercontent.com/microsoft/Windows-Containers/Main/helpful_tools/Install-DockerCE/install-docker-ce.ps1"
|
||||
|
||||
@@ -13,7 +13,7 @@ Function Install-Asset {
|
||||
)
|
||||
|
||||
$releaseAssetName = [System.IO.Path]::GetFileNameWithoutExtension($ReleaseAsset.filename)
|
||||
$assetFolderPath = Join-Path $env:TEMP $releaseAssetName
|
||||
$assetFolderPath = Join-Path $env:TEMP_DIR $releaseAssetName
|
||||
$assetArchivePath = Invoke-DownloadWithRetry $ReleaseAsset.download_url
|
||||
|
||||
Write-Host "Extract $($ReleaseAsset.filename) content..."
|
||||
|
||||
51
images/windows/scripts/build/Invoke-Cleanup.ps1
Normal file
51
images/windows/scripts/build/Invoke-Cleanup.ps1
Normal file
@@ -0,0 +1,51 @@
|
||||
################################################################################
|
||||
## File: Invoke-Cleanup.ps1
|
||||
## Desc: Cleanup WinSxS, temp, cache and compress some directories
|
||||
################################################################################
|
||||
|
||||
Write-Host "Cleanup WinSxS"
|
||||
dism.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Failed to cleanup WinSxS"
|
||||
}
|
||||
|
||||
Write-Host "Clean up various directories"
|
||||
@(
|
||||
"$env:SystemDrive\Recovery",
|
||||
"$env:SystemRoot\logs",
|
||||
"$env:SystemRoot\winsxs\manifestcache",
|
||||
"$env:SystemRoot\Temp",
|
||||
"$env:SystemRoot\Installer",
|
||||
"$env:SystemDrive\Users\$env:INSTALL_USER\AppData\Local\Temp",
|
||||
"$env:TEMP",
|
||||
"$env:AZURE_CONFIG_DIR\logs",
|
||||
"$env:AZURE_CONFIG_DIR\commands",
|
||||
"$env:AZURE_CONFIG_DIR\telemetry"
|
||||
) | ForEach-Object {
|
||||
if (Test-Path $_) {
|
||||
Write-Host "Removing $_"
|
||||
cmd /c "takeown /d Y /R /f $_ 2>&1" | Out-Null
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Failed to take ownership of $_"
|
||||
}
|
||||
cmd /c "icacls $_ /grant:r administrators:f /t /c /q 2>&1" | Out-Null
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Failed to grant administrators full control of $_"
|
||||
}
|
||||
Remove-Item $_ -Recurse -Force -ErrorAction SilentlyContinue | Out-Null
|
||||
}
|
||||
}
|
||||
|
||||
# Remove AllUsersAllHosts profile
|
||||
Remove-Item $profile.AllUsersAllHosts -Force -ErrorAction SilentlyContinue | Out-Null
|
||||
|
||||
# Clean yarn and npm cache
|
||||
cmd /c "yarn cache clean 2>&1" | Out-Null
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Failed to clean yarn cache"
|
||||
}
|
||||
|
||||
cmd /c "npm cache clean --force 2>&1" | Out-Null
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Failed to clean npm cache"
|
||||
}
|
||||
Reference in New Issue
Block a user