Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -1172,7 +1172,7 @@ pipeline {
node('docker && linux'){
def image
checkout scm
timeout(60){
timeout(120){
lock("${env.JOB_NAME} - ${env.NODE_NAME}"){
image = docker.build(UUID.randomUUID().toString(), '-f ci/docker/linux/tox/Dockerfile --build-arg PIP_EXTRA_INDEX_URL --build-arg PIP_INDEX_URL --build-arg UV_EXTRA_INDEX_URL --build-arg UV_INDEX_URL --build-arg PIP_DOWNLOAD_CACHE=/.cache/pip --build-arg UV_CACHE_DIR=/.cache/uv --build-arg CONAN_CENTER_PROXY_V2_URL .')
}
Expand Down
47 changes: 47 additions & 0 deletions scripts/resources/windows/msvc/install_msvc.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ function InstallMSVC{
[string]$VsInstallPath,
[string]$ConfigFile
)
$updateProcesses = @("TiWorker", "TrustedInstaller")

$InstallerFile = "vs_buildtools.exe"
Invoke-WebRequest $VsbuildtoolsURL -OutFile $InstallerFile
Write-Host "Installing Visual Studio Build Tools to ${VsInstallPath}"
Expand Down Expand Up @@ -237,7 +239,49 @@ function InstallMSVC{
}
Write-Host "Cleaning up Package Cache - Done"

Write-Host "Checking for active Windows Update processes..."

Get-WindowsUpdate

# Check if any of these processes are actually running right now
$active = Get-Process -Name $updateProcesses -ErrorAction SilentlyContinue

if ($active) {
$stopwatch = [System.Diagnostics.Stopwatch]::StartNew()
Write-Host "Update in progress. Waiting for completion..."

# Loop while the processes are still active
while (Get-Process -Name $updateProcesses -ErrorAction SilentlyContinue) {
Get-Process -Name $updateProcesses -ErrorAction SilentlyContinue | Format-Table -AutoSize
Write-Host "Updating..."

Start-Sleep -Seconds 30
}

Write-Host "Windows Update processes have finished."
} else {
Write-Host "No active Windows Update detected. Exiting script."
}

# ======== Wait for Windows Update to finish ========
# It seems that installing MSVC build tools triggers Windows
# update. This generates a lot of extra unneeded files for
# the docker layer and bloats the image significantly.
# Waiting for the update to finish and then cleaning up the
# generated files seems to be the best solution to keep the
# layer size down.

$timeout = New-TimeSpan -Hours 2
$stopwatch = [System.Diagnostics.Stopwatch]::StartNew()
$installer = New-Object -ComObject Microsoft.Update.Installer
while ($installer.IsBusy) {
Write-Host "Windows Update is currently busy installing updates. Waiting..."
if ($stopwatch.Elapsed -gt $timeout) {
$stopwatch.Stop()
throw "Timeout exceeded: Operation took longer than 1 hour."
}
Start-Sleep -Seconds 30
}
# ======== Cleanup SoftwareDistribution folder ========
$SoftwareDistributionDownloadPath = "C:\Windows\SoftwareDistribution\Download"
if (Test-Path "$SoftwareDistributionDownloadPath"){
Expand Down Expand Up @@ -340,6 +384,9 @@ function AddStartupScripts{

}

Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
Install-Module PSWindowsUpdate -Force

# ========== Main ==========
InstallMSVC `
-VsbuildtoolsURL $VSBUILDTOOLS_URLS[$VSVersion] `
Expand Down
Loading