diff --git a/images/windows/scripts/build/Install-VisualStudio.ps1 b/images/windows/scripts/build/Install-VisualStudio.ps1 index 5e28bffdd7..bb887353d4 100644 --- a/images/windows/scripts/build/Install-VisualStudio.ps1 +++ b/images/windows/scripts/build/Install-VisualStudio.ps1 @@ -48,6 +48,14 @@ Install-Binary -Type EXE ` -InstallArgs @("/q", "/norestart", "/ceip off", "/features OptionId.UWPManaged OptionId.UWPCPP OptionId.UWPLocalized OptionId.DesktopCPPx86 OptionId.DesktopCPPx64 OptionId.DesktopCPParm64") ` -ExpectedSubject $(Get-MicrosoftPublisher) +if (-not (Test-IsWin22-X64)) { +# Install Windows 11 SDK version 10.0.28000 + Install-Binary -Type EXE ` + -Url 'https://go.microsoft.com/fwlink/?linkid=2366211' ` + -InstallArgs @("/q", "/norestart", "/ceip off", "/features OptionId.UWPManaged OptionId.UWPCPP OptionId.UWPLocalized OptionId.DesktopCPPx86 OptionId.DesktopCPPx64 OptionId.DesktopCPParm64") ` + -ExpectedSubject $(Get-MicrosoftPublisher) +} + # Enable Windows Desktop Debuggers (cdb.exe) on Windows Server 2025 if (Test-IsWin25-X64) { $installerEntry = Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* ` @@ -62,4 +70,11 @@ if (Test-IsWin25-X64) { } } +# Clean installer temp directory +$installerTempPath = "$env:SystemDrive\Users\$env:INSTALL_USER\AppData\Local\Temp" +if (Test-Path $installerTempPath) { + Write-Host "Cleaning $installerTempPath" + Remove-Item -Path "$installerTempPath\*" -Recurse -Force -ErrorAction SilentlyContinue +} + Invoke-PesterTests -TestFile "VisualStudio" diff --git a/images/windows/scripts/build/Install-WindowsUpdates.ps1 b/images/windows/scripts/build/Install-WindowsUpdates.ps1 index c5d22fc99b..18515407de 100644 --- a/images/windows/scripts/build/Install-WindowsUpdates.ps1 +++ b/images/windows/scripts/build/Install-WindowsUpdates.ps1 @@ -4,6 +4,21 @@ ## Should be run at end, just before SoftwareReport and Finalize-VM.ps1. ################################################################################ +# Clean installer temp directory +$installerTempPath = "$env:SystemDrive\Users\$env:INSTALL_USER\AppData\Local\Temp" +if (Test-Path $installerTempPath) { + Write-Host "Cleaning $installerTempPath" + Remove-Item -Path "$installerTempPath\*" -Recurse -Force -ErrorAction SilentlyContinue +} + +Write-Host "Disk space before windows updates" +Get-CimInstance Win32_LogicalDisk -Filter "DriveType = 3" | Sort-Object DeviceID | ForEach-Object { + $totalSpaceGb = [Math]::Round($_.Size / 1GB, 2) + $freeSpaceGb = [Math]::Round($_.FreeSpace / 1GB, 2) + $usedSpaceGb = [Math]::Round(($_.Size - $_.FreeSpace) / 1GB, 2) + Write-Host ("Drive {0}: used {1} GB, free {2} GB, total {3} GB" -f $_.DeviceID, $usedSpaceGb, $freeSpaceGb, $totalSpaceGb) +} + function Install-WindowsUpdates { Write-Host "Starting wuauserv" Start-Service -Name wuauserv -PassThru | Out-Host diff --git a/images/windows/scripts/helpers/InstallHelpers.ps1 b/images/windows/scripts/helpers/InstallHelpers.ps1 index 1569af5519..a3d181f4ce 100644 --- a/images/windows/scripts/helpers/InstallHelpers.ps1 +++ b/images/windows/scripts/helpers/InstallHelpers.ps1 @@ -54,6 +54,8 @@ function Install-Binary { [String] $InstallerLogPath ) + $downloadedInstallerPath = $null + if ($PSCmdlet.ParameterSetName -eq "LocalPath") { if (-not (Test-Path -Path $LocalPath)) { throw "LocalPath parameter is specified, but the file does not exist." @@ -76,6 +78,7 @@ function Install-Binary { $fileName = [System.IO.Path]::GetFileNameWithoutExtension([System.IO.Path]::GetRandomFileName()) + ".$Type".ToLower() } $filePath = Invoke-DownloadWithRetry -Url $Url -Path "${env:TEMP_DIR}\$fileName" + $downloadedInstallerPath = $filePath } if ($PSBoundParameters.ContainsKey('ExpectedSubject')) { @@ -122,8 +125,14 @@ function Install-Binary { $installCompleteTime = [math]::Round(($(Get-Date) - $installStartTime).TotalSeconds, 2) if ($exitCode -eq 0) { Write-Host "Installation successful in $installCompleteTime seconds" + if ($downloadedInstallerPath -and (Test-Path -Path $downloadedInstallerPath)) { + Remove-Item -Path $downloadedInstallerPath -Force -ErrorAction SilentlyContinue + } } elseif ($exitCode -eq 3010) { Write-Host "Installation successful in $installCompleteTime seconds. Reboot is required." + if ($downloadedInstallerPath -and (Test-Path -Path $downloadedInstallerPath)) { + Remove-Item -Path $downloadedInstallerPath -Force -ErrorAction SilentlyContinue + } } else { Write-Host "Installation process returned unexpected exit code: $exitCode" Write-Host "Time elapsed: $installCompleteTime seconds" diff --git a/images/windows/scripts/tests/VisualStudio.Tests.ps1 b/images/windows/scripts/tests/VisualStudio.Tests.ps1 index 2ce4de1ddd..e9cd172550 100644 --- a/images/windows/scripts/tests/VisualStudio.Tests.ps1 +++ b/images/windows/scripts/tests/VisualStudio.Tests.ps1 @@ -35,4 +35,8 @@ Describe "Windows 11 SDK" { It "Verifies 26100 SDK is installed" { "${env:ProgramFiles(x86)}\Windows Kits\10\DesignTime\CommonConfiguration\Neutral\UAP\10.0.26100.0\UAP.props" | Should -Exist } + + It "Verifies 28000 SDK is installed" -Skip:(Test-IsWin22-X64) { + "${env:ProgramFiles(x86)}\Windows Kits\10\DesignTime\CommonConfiguration\Neutral\UAP\10.0.28000.0\UAP.props" | Should -Exist + } } diff --git a/images/windows/templates/build.windows-11-vs2026-arm64.pkr.hcl b/images/windows/templates/build.windows-11-vs2026-arm64.pkr.hcl index f0f3d8e8fe..c8b2016714 100644 --- a/images/windows/templates/build.windows-11-vs2026-arm64.pkr.hcl +++ b/images/windows/templates/build.windows-11-vs2026-arm64.pkr.hcl @@ -123,7 +123,7 @@ build { provisioner "windows-restart" { check_registry = true - restart_timeout = "10m" + restart_timeout = "30m" } provisioner "powershell" { diff --git a/images/windows/templates/build.windows-2025-vs2026.pkr.hcl b/images/windows/templates/build.windows-2025-vs2026.pkr.hcl index 2824b79ed6..85abb839ae 100644 --- a/images/windows/templates/build.windows-2025-vs2026.pkr.hcl +++ b/images/windows/templates/build.windows-2025-vs2026.pkr.hcl @@ -105,7 +105,8 @@ build { environment_vars = ["IMAGE_FOLDER=${var.image_folder}", "TEMP_DIR=${var.temp_dir}", "INSTALL_VS_2026=true"] scripts = [ "${path.root}/../scripts/build/Install-VisualStudio.ps1", - "${path.root}/../scripts/build/Install-KubernetesTools.ps1" + "${path.root}/../scripts/build/Install-KubernetesTools.ps1", + "${path.root}/../scripts/build/Install-LLVM.ps1", ] valid_exit_codes = [0, 3010] } @@ -198,8 +199,7 @@ build { "${path.root}/../scripts/build/Configure-DynamicPort.ps1", "${path.root}/../scripts/build/Configure-GDIProcessHandleQuota.ps1", "${path.root}/../scripts/build/Configure-Shell.ps1", - "${path.root}/../scripts/build/Configure-DeveloperMode.ps1", - "${path.root}/../scripts/build/Install-LLVM.ps1" + "${path.root}/../scripts/build/Configure-DeveloperMode.ps1" ] } diff --git a/images/windows/templates/build.windows-2025.pkr.hcl b/images/windows/templates/build.windows-2025.pkr.hcl index 59e45e6726..f3a250227a 100644 --- a/images/windows/templates/build.windows-2025.pkr.hcl +++ b/images/windows/templates/build.windows-2025.pkr.hcl @@ -105,7 +105,8 @@ build { environment_vars = ["IMAGE_FOLDER=${var.image_folder}", "TEMP_DIR=${var.temp_dir}"] scripts = [ "${path.root}/../scripts/build/Install-VisualStudio.ps1", - "${path.root}/../scripts/build/Install-KubernetesTools.ps1" + "${path.root}/../scripts/build/Install-KubernetesTools.ps1", + "${path.root}/../scripts/build/Install-LLVM.ps1" ] valid_exit_codes = [0, 3010] } @@ -198,8 +199,7 @@ build { "${path.root}/../scripts/build/Configure-DynamicPort.ps1", "${path.root}/../scripts/build/Configure-GDIProcessHandleQuota.ps1", "${path.root}/../scripts/build/Configure-Shell.ps1", - "${path.root}/../scripts/build/Configure-DeveloperMode.ps1", - "${path.root}/../scripts/build/Install-LLVM.ps1" + "${path.root}/../scripts/build/Configure-DeveloperMode.ps1" ] }