Skip to content
Open
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
15 changes: 15 additions & 0 deletions images/windows/scripts/build/Install-VisualStudio.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Comment on lines +52 to +56

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mune

}

# Enable Windows Desktop Debuggers (cdb.exe) on Windows Server 2025
if (Test-IsWin25-X64) {
$installerEntry = Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* `
Expand All @@ -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"
15 changes: 15 additions & 0 deletions images/windows/scripts/build/Install-WindowsUpdates.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions images/windows/scripts/helpers/InstallHelpers.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand All @@ -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')) {
Expand Down Expand Up @@ -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"
Expand Down
4 changes: 4 additions & 0 deletions images/windows/scripts/tests/VisualStudio.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ build {

provisioner "windows-restart" {
check_registry = true
restart_timeout = "10m"
restart_timeout = "30m"
}

provisioner "powershell" {
Expand Down
6 changes: 3 additions & 3 deletions images/windows/templates/build.windows-2025-vs2026.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -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]
}
Expand Down Expand Up @@ -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"
]
}

Expand Down
6 changes: 3 additions & 3 deletions images/windows/templates/build.windows-2025.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -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]
}
Expand Down Expand Up @@ -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"
]
}

Expand Down
Loading