refactor(§7.5): rinomina Setup-* Install-CIToolchain-* (WinBuild2025/2022/Linux2404)

- template/Setup-WinBuild2025.ps1  Install-CIToolchain-WinBuild2025.ps1
- template/Setup-WinBuild2022.ps1  Install-CIToolchain-WinBuild2022.ps1
- template/Setup-LinuxBuild2404.sh  Install-CIToolchain-Linux2404.sh

Aggiornati tutti i riferimenti in: Prepare-WinBuild2025/2022, Prepare-LinuxBuild2404,
Deploy-WinBuild2025/2022/LinuxBuild2404, Validate-DeployState, Validate-SetupState,
README.md, TODO.md, docs/WINDOWS-TEMPLATE-SETUP.md, docs/LINUX-TEMPLATE-SETUP.md,
docs/TEST-PLAN-v1.3-to-HEAD.md, gitea/actions/local-ci-build/action.yml.

§7 chiuso (5/5 done).
This commit is contained in:
Simone
2026-05-11 22:48:33 +02:00
parent 6511d47a9a
commit 4758fbc519
17 changed files with 158 additions and 134 deletions
+3 -2
View File
@@ -1,4 +1,4 @@
#Requires -Version 5.1
#Requires -Version 5.1
<#
.SYNOPSIS
Deploys an Ubuntu 24.04 LTS build VM on VMware Workstation using a cloud
@@ -24,7 +24,7 @@
both files and creates the $CloudUser account with the SSH public key.
No packages are installed and no runcmd runs: all provisioning (apt,
toolchain, SSH hardening, swap) is handled by Prepare-LinuxBuild2404.ps1
via Setup-LinuxBuild2404.sh. Step 9 waits for
via Install-CIToolchain-Linux2404.sh. Step 9 waits for
/var/lib/cloud/instance/boot-finished before proceeding.
NIC:
@@ -676,3 +676,4 @@ Write-Host " Next steps (from template\ dir):"
Write-Host " .\Prepare-LinuxBuild2404.ps1 -VMXPath '$VMXPath' -VMIPAddress $guestIP"
Write-Host ""
Write-Host " VM is powered on. cloud-init provisioning complete." -ForegroundColor Green
+8 -7
View File
@@ -1,4 +1,4 @@
#Requires -RunAsAdministrator
#Requires -RunAsAdministrator
#Requires -Version 5.1
<#
.SYNOPSIS
@@ -39,7 +39,7 @@
- Defender real-time protection off + DisableAntiSpyware=1 GPO
- DiagTrack/Telemetry off
- Windows Update GPO locks (NoAutoUpdate=1, DisableWindowsUpdateAccess=1);
services remain Manual — Setup-WinBuild2022 Step 6b permanently disables
services remain Manual — Install-CIToolchain-WinBuild2022 Step 6b permanently disables
them after applying updates (§7.2 Strategy B)
- Windows Firewall all profiles disabled (VMnet8 NAT lab; Setup Step 1 validates)
- RDP enabled (no NLA, lab only) + firewall rules for RDP/ICMP/WinRM-HTTPS
@@ -48,7 +48,7 @@
- ICMPv4 inbound allowed
- Lock screen disabled, Server Manager (policy + HKLM + task + HKCU + Default hive),
DisableCAD (Policies\System + Winlogon), OOBE/telemetry suppressed;
Setup-WinBuild2022 Step 5b/5c validate all of these
Install-CIToolchain-WinBuild2022 Step 5b/5c validate all of these
- Taskbar search bar hidden, Task View button hidden
- Windows Terminal set as default terminal (DelegationConsole/Terminal HKCU + Default hive)
- Azure Arc auto-start, scheduled tasks, and himds service disabled
@@ -580,9 +580,9 @@ reg add 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System' /v Enab
reg add 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System' /v LocalAccountTokenFilterPolicy /t REG_DWORD /d 1 /f | Out-Null
L 'UAC disabled'
# Defender disabled (lab only) Setup-WinBuild2022 skips Defender step
# Defender disabled (lab only) Install-CIToolchain-WinBuild2022 skips Defender step
# RTP off + tamper-protect GPO. With Defender fully off, exclusion paths
# become moot (no scanner to exclude from), so Setup-WinBuild2022 has been
# become moot (no scanner to exclude from), so Install-CIToolchain-WinBuild2022 has been
# stripped of its Defender step.
try { Set-MpPreference -DisableRealtimeMonitoring `$true -ErrorAction Stop; L 'Defender RTP off' }
catch { L "Defender RTP off failed: `$(`$_.Exception.Message)" }
@@ -608,7 +608,7 @@ L 'Windows Update GPO locks set + wuauserv/UsoSvc Manual (Setup Step 6b permanen
# Firewall: all profiles disabled + allow RDP + ICMP + WinRM HTTPS
# Disabling all profiles removes any block on subsequent WinRM config and WU
# downloads. This VM lives on VMnet8 NAT behind the VMware NAT gateway no
# inbound exposure from outside the host. Setup-WinBuild2022 Step 1 validates.
# inbound exposure from outside the host. Install-CIToolchain-WinBuild2022 Step 1 validates.
Set-NetFirewallProfile -Profile Domain,Private,Public -Enabled False
L 'Windows Firewall disabled on all profiles'
reg add 'HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server' /v fDenyTSConnections /t REG_DWORD /d 0 /f | Out-Null
@@ -650,7 +650,7 @@ reg add 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System' /v Disa
# OOBE privacy experience suppressed
reg add 'HKLM\SOFTWARE\Policies\Microsoft\Windows\OOBE' /v DisablePrivacyExperience /t REG_DWORD /d 1 /f | Out-Null
L 'Server Manager + WAC + CAD + OOBE prompts disabled'
# Supplemental UX hardening validated by Setup-WinBuild2022 Step 5c:
# Supplemental UX hardening validated by Install-CIToolchain-WinBuild2022 Step 5c:
# Lock screen: suppress at CI console sessions (no interactive user ever logs in)
reg add 'HKLM\SOFTWARE\Policies\Microsoft\Windows\Personalization' /v NoLockScreen /t REG_DWORD /d 1 /f | Out-Null
# Server Manager GPO policy key (authoritative path on WS2022; HKLM key above is not always honoured)
@@ -1114,3 +1114,4 @@ Write-Host " .\Validate-DeployState.ps1 -VMIPAddress $guestIP"
Write-Host " .\Prepare-WinBuild2022.ps1 -VMIPAddress $guestIP [-SkipWindowsUpdate]"
Write-Host ""
Write-Host " VM is powered on with vmxnet3 + DHCP. Snapshot '$SnapshotName' taken." -ForegroundColor Green
+8 -7
View File
@@ -1,4 +1,4 @@
#Requires -RunAsAdministrator
#Requires -RunAsAdministrator
#Requires -Version 5.1
<#
.SYNOPSIS
@@ -39,7 +39,7 @@
- Defender real-time protection off + DisableAntiSpyware=1 GPO
- DiagTrack/Telemetry off
- Windows Update GPO locks (NoAutoUpdate=1, DisableWindowsUpdateAccess=1);
services remain Manual — Setup-WinBuild2025 Step 6b permanently disables
services remain Manual — Install-CIToolchain-WinBuild2025 Step 6b permanently disables
them after applying updates (§7.2 Strategy B)
- Windows Firewall all profiles disabled (VMnet8 NAT lab; Setup Step 1 validates)
- RDP enabled (no NLA, lab only) + firewall rules for RDP/ICMP/WinRM-HTTPS
@@ -48,7 +48,7 @@
- ICMPv4 inbound allowed
- Lock screen disabled, Server Manager (policy + HKLM + task + HKCU + Default hive),
DisableCAD (Policies\System + Winlogon), OOBE/telemetry suppressed;
Setup-WinBuild2025 Step 5b/5c validate all of these
Install-CIToolchain-WinBuild2025 Step 5b/5c validate all of these
- Taskbar search bar hidden, Task View button hidden
- Windows Terminal set as default terminal (DelegationConsole/Terminal HKCU + Default hive)
- Azure Arc auto-start, scheduled tasks, and himds service disabled
@@ -580,9 +580,9 @@ reg add 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System' /v Enab
reg add 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System' /v LocalAccountTokenFilterPolicy /t REG_DWORD /d 1 /f | Out-Null
L 'UAC disabled'
# Defender disabled (lab only) Setup-WinBuild2025 skips Defender step
# Defender disabled (lab only) Install-CIToolchain-WinBuild2025 skips Defender step
# RTP off + tamper-protect GPO. With Defender fully off, exclusion paths
# become moot (no scanner to exclude from), so Setup-WinBuild2025 has been
# become moot (no scanner to exclude from), so Install-CIToolchain-WinBuild2025 has been
# stripped of its Defender step.
try { Set-MpPreference -DisableRealtimeMonitoring `$true -ErrorAction Stop; L 'Defender RTP off' }
catch { L "Defender RTP off failed: `$(`$_.Exception.Message)" }
@@ -608,7 +608,7 @@ L 'Windows Update GPO locks set + wuauserv/UsoSvc Manual (Setup Step 6b permanen
# Firewall: all profiles disabled + allow RDP + ICMP + WinRM HTTPS
# Disabling all profiles removes any block on subsequent WinRM config and WU
# downloads. This VM lives on VMnet8 NAT behind the VMware NAT gateway no
# inbound exposure from outside the host. Setup-WinBuild2025 Step 1 validates.
# inbound exposure from outside the host. Install-CIToolchain-WinBuild2025 Step 1 validates.
Set-NetFirewallProfile -Profile Domain,Private,Public -Enabled False
L 'Windows Firewall disabled on all profiles'
reg add 'HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server' /v fDenyTSConnections /t REG_DWORD /d 0 /f | Out-Null
@@ -650,7 +650,7 @@ reg add 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System' /v Disa
# OOBE privacy experience suppressed
reg add 'HKLM\SOFTWARE\Policies\Microsoft\Windows\OOBE' /v DisablePrivacyExperience /t REG_DWORD /d 1 /f | Out-Null
L 'Server Manager + WAC + CAD + OOBE prompts disabled'
# Supplemental UX hardening validated by Setup-WinBuild2025 Step 5c:
# Supplemental UX hardening validated by Install-CIToolchain-WinBuild2025 Step 5c:
# Lock screen: suppress at CI console sessions (no interactive user ever logs in)
reg add 'HKLM\SOFTWARE\Policies\Microsoft\Windows\Personalization' /v NoLockScreen /t REG_DWORD /d 1 /f | Out-Null
# Server Manager GPO policy key (authoritative path on WS2025; HKLM key above is not always honoured)
@@ -1114,3 +1114,4 @@ Write-Host " .\Validate-DeployState.ps1 -VMIPAddress $guestIP"
Write-Host " .\Prepare-WinBuild2025.ps1 -VMIPAddress $guestIP [-SkipWindowsUpdate]"
Write-Host ""
Write-Host " VM is powered on with vmxnet3 + DHCP. Snapshot '$SnapshotName' taken." -ForegroundColor Green
@@ -1,11 +1,11 @@
#!/usr/bin/env bash
# Setup-LinuxBuild2404.sh
# Install-CIToolchain-Linux2404.sh
# Guest-side CI toolchain setup for Ubuntu 24.04 LTS build template.
# Run as ci_build (passwordless sudo) via: sudo /tmp/Setup-LinuxBuild2404.sh
# Run as ci_build (passwordless sudo) via: sudo /tmp/Install-CIToolchain-Linux2404.sh
# Called by: template/Prepare-LinuxBuild2404.ps1 (host-side)
#
# Usage:
# sudo /tmp/Setup-LinuxBuild2404.sh [--skip-update] [--dotnet] [--mingw]
# sudo /tmp/Install-CIToolchain-Linux2404.sh [--skip-update] [--dotnet] [--mingw]
#
# Options:
# --skip-update Skip apt update + upgrade (faster re-runs)
@@ -265,6 +265,7 @@ assert_step "/tmp writable" bash -c 'touch /tmp/.ci_tmpcheck && rm /tmp/.ci_tmpc
assert_step "ci-report-ip.service enabled" systemctl is-enabled ci-report-ip.service
echo ""
echo "=== Setup-LinuxBuild2404.sh complete ==="
echo "=== Install-CIToolchain-Linux2404.sh complete ==="
echo " All steps passed. VM is ready for BaseClean-Linux snapshot."
echo " Run Prepare-LinuxBuild2404.ps1 --Step7Shutdown + snapshot from host."
@@ -1,4 +1,4 @@
#Requires -RunAsAdministrator
#Requires -RunAsAdministrator
#Requires -Version 5.1
<#
.SYNOPSIS
@@ -121,7 +121,7 @@
Invoke via Prepare-WinBuild2022.ps1 from the HOST (recommended), or
run manually from an elevated PowerShell session INSIDE the VM:
Set-ExecutionPolicy Bypass -Scope Process -Force
.\Setup-WinBuild2022.ps1 -BuildPassword 'YourPassword'
.\Install-CIToolchain-WinBuild2022.ps1 -BuildPassword 'YourPassword'
#>
[CmdletBinding()]
param(
@@ -1715,8 +1715,9 @@ Write-Host "All pre-snapshot checks passed." -ForegroundColor Green
# ── Done ──────────────────────────────────────────────────────────────────────
Write-Host ""
Write-Host "Setup-WinBuild2022.ps1 complete. All Assert-Step checks passed." -ForegroundColor Green
Write-Host "Install-CIToolchain-WinBuild2022.ps1 complete. All Assert-Step checks passed." -ForegroundColor Green
# Full next-steps banner is printed by Prepare-WinBuild2022.ps1 on the host.
# If running this script standalone (manually inside the VM), follow the steps
# in docs/WINDOWS-TEMPLATE-SETUP.md (shut down → snapshot BaseClean → power off).
Write-Host ""
@@ -1,4 +1,4 @@
#Requires -RunAsAdministrator
#Requires -RunAsAdministrator
#Requires -Version 5.1
<#
.SYNOPSIS
@@ -121,7 +121,7 @@
Invoke via Prepare-WinBuild2025.ps1 from the HOST (recommended), or
run manually from an elevated PowerShell session INSIDE the VM:
Set-ExecutionPolicy Bypass -Scope Process -Force
.\Setup-WinBuild2025.ps1 -BuildPassword 'YourPassword'
.\Install-CIToolchain-WinBuild2025.ps1 -BuildPassword 'YourPassword'
#>
[CmdletBinding()]
param(
@@ -1715,8 +1715,9 @@ Write-Host "All pre-snapshot checks passed." -ForegroundColor Green
# ── Done ──────────────────────────────────────────────────────────────────────
Write-Host ""
Write-Host "Setup-WinBuild2025.ps1 complete. All Assert-Step checks passed." -ForegroundColor Green
Write-Host "Install-CIToolchain-WinBuild2025.ps1 complete. All Assert-Step checks passed." -ForegroundColor Green
# Full next-steps banner is printed by Prepare-WinBuild2025.ps1 on the host.
# If running this script standalone (manually inside the VM), follow the steps
# in docs/WINDOWS-TEMPLATE-SETUP.md (shut down → snapshot BaseClean → power off).
Write-Host ""
+17 -16
View File
@@ -1,7 +1,7 @@
#Requires -Version 5.1
#Requires -Version 5.1
<#
.SYNOPSIS
HOST-side script: delivers and runs Setup-LinuxBuild2404.sh inside the Linux template VM.
HOST-side script: delivers and runs Install-CIToolchain-Linux2404.sh inside the Linux template VM.
.DESCRIPTION
Automates provisioning of the Ubuntu 24.04 template VM from the host machine via SSH/SCP:
@@ -9,8 +9,8 @@
IPv4 address valid, TCP/22 reachable
2. Auto power-on + guest IP detection via vmrun getGuestIPAddress (when -VMXPath provided)
3. Add host key to known_hosts (idempotent, uses StrictHostKeyChecking=accept-new)
4. Copy Setup-LinuxBuild2404.sh to /tmp on guest via scp + validate file size
5. Execute Setup-LinuxBuild2404.sh via SSH (stdout/stderr streamed to host console)
4. Copy Install-CIToolchain-Linux2404.sh to /tmp on guest via scp + validate file size
5. Execute Install-CIToolchain-Linux2404.sh via SSH (stdout/stderr streamed to host console)
6. Post-setup remote validation batch check (user, sudo, tools, CI dirs, swap, sshd)
7. Graceful shutdown + vmrun snapshot (when -TakeSnapshot or -VMXPath provided)
Final: print summary
@@ -56,13 +56,13 @@
Must match the snapshot name used in New-BuildVM.ps1.
.PARAMETER SkipUpdate
Pass --skip-update to Setup-LinuxBuild2404.sh (skips apt-get upgrade).
Pass --skip-update to Install-CIToolchain-Linux2404.sh (skips apt-get upgrade).
.PARAMETER InstallDotNet
Pass --dotnet to Setup-LinuxBuild2404.sh (installs .NET SDK).
Pass --dotnet to Install-CIToolchain-Linux2404.sh (installs .NET SDK).
.PARAMETER NoMingw
Pass --no-mingw to Setup-LinuxBuild2404.sh (skips MinGW cross-compiler).
Pass --no-mingw to Install-CIToolchain-Linux2404.sh (skips MinGW cross-compiler).
MinGW is installed by default; use this only to skip it.
.PARAMETER TakeSnapshot
@@ -278,26 +278,26 @@ if ($LASTEXITCODE -ne 0) {
}
Write-Host " [OK] SSH connectivity confirmed, host key added."
# ── Step 5 — Copy Setup-LinuxBuild2404.sh into VM ────────────────────────────
Write-Host "[Prepare] Step 5 — Copying Setup-LinuxBuild2404.sh to guest..."
# ── Step 5 — Copy Install-CIToolchain-Linux2404.sh into VM ────────────────────────────
Write-Host "[Prepare] Step 5 — Copying Install-CIToolchain-Linux2404.sh to guest..."
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$setupScript = Join-Path $scriptDir 'Setup-LinuxBuild2404.sh'
$guestScript = '/tmp/Setup-LinuxBuild2404.sh'
$setupScript = Join-Path $scriptDir 'Install-CIToolchain-Linux2404.sh'
$guestScript = '/tmp/Install-CIToolchain-Linux2404.sh'
if (-not (Test-Path $setupScript -PathType Leaf)) {
throw "[Prepare Step 5] Setup-LinuxBuild2404.sh not found alongside this script: $setupScript"
throw "[Prepare Step 5] Install-CIToolchain-Linux2404.sh not found alongside this script: $setupScript"
}
# Strip UTF-8 BOM and normalize CRLF→LF before copying.
# PS 5.1 / VS Code on Windows may save .sh files with BOM or CRLF; both break bash.
$shBytes = [System.IO.File]::ReadAllBytes($setupScript)
if ($shBytes.Length -ge 3 -and $shBytes[0] -eq 0xEF -and $shBytes[1] -eq 0xBB -and $shBytes[2] -eq 0xBF) {
Write-Host " [WARN] UTF-8 BOM detected in Setup-LinuxBuild2404.sh — stripping before copy"
Write-Host " [WARN] UTF-8 BOM detected in Install-CIToolchain-Linux2404.sh — stripping before copy"
$shBytes = $shBytes[3..($shBytes.Length - 1)]
}
$shText = [System.Text.Encoding]::UTF8.GetString($shBytes) -replace "`r`n", "`n" -replace "`r", "`n"
$tmpScript = Join-Path $env:TEMP 'Setup-LinuxBuild2404-ci.sh'
$tmpScript = Join-Path $env:TEMP 'Install-CIToolchain-Linux2404-ci.sh'
[System.IO.File]::WriteAllText($tmpScript, $shText, [System.Text.UTF8Encoding]::new($false))
$setupScript = $tmpScript
@@ -322,7 +322,7 @@ Assert-Step 'FileCopy' "guest script size matches local ($localSize bytes, remot
}
# ── Step 6 — Execute setup script ────────────────────────────────────────────
Write-Host "[Prepare] Step 6 — Running Setup-LinuxBuild2404.sh in guest (may take several minutes)..."
Write-Host "[Prepare] Step 6 — Running Install-CIToolchain-Linux2404.sh in guest (may take several minutes)..."
$setupFlags = [System.Collections.Generic.List[string]]::new()
if ($SkipUpdate) { $setupFlags.Add('--skip-update') }
@@ -340,7 +340,7 @@ $setupExitCode = $LASTEXITCODE
Write-Host "------------------------------------------------------------"
if ($setupExitCode -ne 0) {
throw "[Prepare Step 6] Setup-LinuxBuild2404.sh exited $setupExitCode — see output above."
throw "[Prepare Step 6] Install-CIToolchain-Linux2404.sh exited $setupExitCode — see output above."
}
Write-Host "[Prepare] Setup script completed (exit 0)." -ForegroundColor Green
@@ -435,3 +435,4 @@ if ($TakeSnapshot -or $VMXPath -ne '') {
} else {
Write-Host " Snapshot: not taken — run manually then use -SnapshotName '$SnapshotName'"
}
+20 -18
View File
@@ -1,7 +1,7 @@
#Requires -Version 5.1
#Requires -Version 5.1
<#
.SYNOPSIS
HOST-side script: delivers and runs Setup-WinBuild2022.ps1 inside the template VM.
HOST-side script: delivers and runs Install-CIToolchain-WinBuild2022.ps1 inside the template VM.
.DESCRIPTION
Automates the template VM provisioning from the host machine:
@@ -12,8 +12,8 @@
(PS 5.1 Test-WSMan has no -SessionOption, so PSSession is used as the connectivity probe)
5. PSSession open — step 4 and 5 are now merged
6. Ensures C:\CI exists on guest; validates creation
7. Copies Setup-WinBuild2022.ps1 into the VM; validates file present + size match
8. Runs Setup-WinBuild2022.ps1 inside the VM with the given parameters
7. Copies Install-CIToolchain-WinBuild2022.ps1 into the VM; validates file present + size match
8. Runs Install-CIToolchain-WinBuild2022.ps1 inside the VM with the given parameters
(Setup performs per-step validation internally — aborts on any failure)
9. Handles the reboot-required case (exit 3010) and optionally re-runs
10. Post-setup remote validation: 9 guest-state checks via a single Invoke-Command
@@ -68,13 +68,13 @@
.PARAMETER BuildUsername
Local username for the CI build account inside the VM. Default: ci_build.
Passed through to Setup-WinBuild2022.ps1 and used in post-setup validation.
Passed through to Install-CIToolchain-WinBuild2022.ps1 and used in post-setup validation.
.PARAMETER DotNetSdkVersion
.NET SDK channel to install in the VM. Default: 10.0 (matches host SDK).
.PARAMETER SkipWindowsUpdate
Pass through to Setup-WinBuild2022.ps1 to skip the Windows Update step.
Pass through to Install-CIToolchain-WinBuild2022.ps1 to skip the Windows Update step.
.PARAMETER SnapshotName
Name of the snapshot to create. Default: BaseClean (case-sensitive — used by New-BuildVM.ps1).
@@ -132,7 +132,7 @@ param(
[string] $DotNetSdkVersion = '10.0',
# Tier-2 Toolchain version pins — forwarded as-is to Setup-WinBuild2022.ps1
# Tier-2 Toolchain version pins — forwarded as-is to Install-CIToolchain-WinBuild2022.ps1
[string] $Pwsh7Version = '7.6.1',
[string] $NSISVersion = '3.12',
[string] $CMakeVersion = '3.31.6',
@@ -141,7 +141,7 @@ param(
[string] $GhCliVersion = '2.92.0',
[string] $VcpkgRef = '',
# Skip Tier-2 Toolchain — forwarded to Setup-WinBuild2022.ps1 -SkipTier2
# Skip Tier-2 Toolchain — forwarded to Install-CIToolchain-WinBuild2022.ps1 -SkipTier2
[switch] $SkipTier2,
[switch] $SkipWindowsUpdate,
@@ -231,8 +231,8 @@ $scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
# Pre-flight validation
Assert-Step 'PreFlight' 'script directory resolved' { Test-Path $scriptDir -PathType Container }
Assert-Step 'PreFlight' 'Setup-WinBuild2022.ps1 present alongside this script' {
Test-Path (Join-Path $scriptDir 'Setup-WinBuild2022.ps1') -PathType Leaf
Assert-Step 'PreFlight' 'Install-CIToolchain-WinBuild2022.ps1 present alongside this script' {
Test-Path (Join-Path $scriptDir 'Install-CIToolchain-WinBuild2022.ps1') -PathType Leaf
}
Assert-Step 'PreFlight' "VMIPAddress octets in 0..255" {
$parts = $VMIPAddress.Split('.') | ForEach-Object { [int]$_ }
@@ -330,9 +330,9 @@ Error: $_
}
try {
# ── Copy Setup-WinBuild2022.ps1 into the VM ───────────────────────────────
$setupScript = Join-Path $scriptDir 'Setup-WinBuild2022.ps1'
$guestScriptPath = 'C:\CI\Setup-WinBuild2022.ps1'
# ── Copy Install-CIToolchain-WinBuild2022.ps1 into the VM ───────────────────────────────
$setupScript = Join-Path $scriptDir 'Install-CIToolchain-WinBuild2022.ps1'
$guestScriptPath = 'C:\CI\Install-CIToolchain-WinBuild2022.ps1'
Write-Host "[Prepare] Ensuring C:\CI exists on guest..."
Invoke-Command -Session $session -ScriptBlock {
@@ -344,7 +344,7 @@ try {
Invoke-Command -Session $session -ScriptBlock { Test-Path 'C:\CI' -PathType Container }
}
Write-Host "[Prepare] Copying Setup-WinBuild2022.ps1 -> guest $guestScriptPath (UTF-8 BOM)..."
Write-Host "[Prepare] Copying Install-CIToolchain-WinBuild2022.ps1 -> guest $guestScriptPath (UTF-8 BOM)..."
# Do NOT use Copy-Item -ToSession: it binary-copies the file.
# If the source file has no UTF-8 BOM, PowerShell 5.1 on the guest reads it as
# Windows-1252, misinterpreting multi-byte UTF-8 sequences (e.g. em dash U+2014
@@ -374,7 +374,7 @@ try {
[int64]$remoteSize -ge ([int64]$hostSize - 6) -and [int64]$remoteSize -le ([int64]$hostSize + 6)
}
# ── Build argument list for Setup-WinBuild2022.ps1 ───────────────────────
# ── Build argument list for Install-CIToolchain-WinBuild2022.ps1 ───────────────────────
$setupArgs = @{
BuildPassword = $BuildPassword
BuildUsername = $BuildUsername
@@ -392,7 +392,7 @@ try {
if ($SkipCleanup) { $setupArgs['SkipCleanup'] = $true }
if ($SkipTier2) { $setupArgs['SkipTier2'] = $true }
# ── Run Setup-WinBuild2022.ps1 inside the VM ──────────────────────────────
# ── Run Install-CIToolchain-WinBuild2022.ps1 inside the VM ──────────────────────────────
# Setup may return exit 3010 (ERROR_SUCCESS_REBOOT_REQUIRED) when Windows
# Update applied patches that need a reboot. We loop: reboot guest, wait for
# WinRM, reopen session, re-invoke Setup. Steps 1-5 are idempotent (~30 s);
@@ -441,7 +441,7 @@ try {
return $false
}
Write-Host "[Prepare] Running Setup-WinBuild2022.ps1 inside VM (this will take a while)..."
Write-Host "[Prepare] Running Install-CIToolchain-WinBuild2022.ps1 inside VM (this will take a while)..."
for ($iter = 1; $iter -le $maxWuIterations; $iter++) {
Write-Host "[Prepare] Setup iteration $iter/$maxWuIterations"
@@ -466,7 +466,7 @@ try {
if ($result -eq 0) { break }
if ($result -ne 3010) {
throw "Setup-WinBuild2022.ps1 exited with code $result"
throw "Install-CIToolchain-WinBuild2022.ps1 exited with code $result"
}
# exit 3010 (or transport error treated as 3010) → WU needs reboot.
@@ -721,3 +721,5 @@ finally {
}
Write-Host "[Prepare] Host TrustedHosts restored."
}
+20 -18
View File
@@ -1,7 +1,7 @@
#Requires -Version 5.1
#Requires -Version 5.1
<#
.SYNOPSIS
HOST-side script: delivers and runs Setup-WinBuild2025.ps1 inside the template VM.
HOST-side script: delivers and runs Install-CIToolchain-WinBuild2025.ps1 inside the template VM.
.DESCRIPTION
Automates the template VM provisioning from the host machine:
@@ -12,8 +12,8 @@
(PS 5.1 Test-WSMan has no -SessionOption, so PSSession is used as the connectivity probe)
5. PSSession open — step 4 and 5 are now merged
6. Ensures C:\CI exists on guest; validates creation
7. Copies Setup-WinBuild2025.ps1 into the VM; validates file present + size match
8. Runs Setup-WinBuild2025.ps1 inside the VM with the given parameters
7. Copies Install-CIToolchain-WinBuild2025.ps1 into the VM; validates file present + size match
8. Runs Install-CIToolchain-WinBuild2025.ps1 inside the VM with the given parameters
(Setup performs per-step validation internally — aborts on any failure)
9. Handles the reboot-required case (exit 3010) and optionally re-runs
10. Post-setup remote validation: 9 guest-state checks via a single Invoke-Command
@@ -68,13 +68,13 @@
.PARAMETER BuildUsername
Local username for the CI build account inside the VM. Default: ci_build.
Passed through to Setup-WinBuild2025.ps1 and used in post-setup validation.
Passed through to Install-CIToolchain-WinBuild2025.ps1 and used in post-setup validation.
.PARAMETER DotNetSdkVersion
.NET SDK channel to install in the VM. Default: 10.0 (matches host SDK).
.PARAMETER SkipWindowsUpdate
Pass through to Setup-WinBuild2025.ps1 to skip the Windows Update step.
Pass through to Install-CIToolchain-WinBuild2025.ps1 to skip the Windows Update step.
.PARAMETER SnapshotName
Name of the snapshot to create. Default: BaseClean (case-sensitive — used by New-BuildVM.ps1).
@@ -132,7 +132,7 @@ param(
[string] $DotNetSdkVersion = '10.0',
# Tier-2 Toolchain version pins — forwarded as-is to Setup-WinBuild2025.ps1
# Tier-2 Toolchain version pins — forwarded as-is to Install-CIToolchain-WinBuild2025.ps1
[string] $Pwsh7Version = '7.6.1',
[string] $NSISVersion = '3.12',
[string] $CMakeVersion = '3.31.6',
@@ -141,7 +141,7 @@ param(
[string] $GhCliVersion = '2.92.0',
[string] $VcpkgRef = '',
# Skip Tier-2 Toolchain — forwarded to Setup-WinBuild2025.ps1 -SkipTier2
# Skip Tier-2 Toolchain — forwarded to Install-CIToolchain-WinBuild2025.ps1 -SkipTier2
[switch] $SkipTier2,
[switch] $SkipWindowsUpdate,
@@ -231,8 +231,8 @@ $scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
# Pre-flight validation
Assert-Step 'PreFlight' 'script directory resolved' { Test-Path $scriptDir -PathType Container }
Assert-Step 'PreFlight' 'Setup-WinBuild2025.ps1 present alongside this script' {
Test-Path (Join-Path $scriptDir 'Setup-WinBuild2025.ps1') -PathType Leaf
Assert-Step 'PreFlight' 'Install-CIToolchain-WinBuild2025.ps1 present alongside this script' {
Test-Path (Join-Path $scriptDir 'Install-CIToolchain-WinBuild2025.ps1') -PathType Leaf
}
Assert-Step 'PreFlight' "VMIPAddress octets in 0..255" {
$parts = $VMIPAddress.Split('.') | ForEach-Object { [int]$_ }
@@ -330,9 +330,9 @@ Error: $_
}
try {
# ── Copy Setup-WinBuild2025.ps1 into the VM ───────────────────────────────
$setupScript = Join-Path $scriptDir 'Setup-WinBuild2025.ps1'
$guestScriptPath = 'C:\CI\Setup-WinBuild2025.ps1'
# ── Copy Install-CIToolchain-WinBuild2025.ps1 into the VM ───────────────────────────────
$setupScript = Join-Path $scriptDir 'Install-CIToolchain-WinBuild2025.ps1'
$guestScriptPath = 'C:\CI\Install-CIToolchain-WinBuild2025.ps1'
Write-Host "[Prepare] Ensuring C:\CI exists on guest..."
Invoke-Command -Session $session -ScriptBlock {
@@ -344,7 +344,7 @@ try {
Invoke-Command -Session $session -ScriptBlock { Test-Path 'C:\CI' -PathType Container }
}
Write-Host "[Prepare] Copying Setup-WinBuild2025.ps1 -> guest $guestScriptPath (UTF-8 BOM)..."
Write-Host "[Prepare] Copying Install-CIToolchain-WinBuild2025.ps1 -> guest $guestScriptPath (UTF-8 BOM)..."
# Do NOT use Copy-Item -ToSession: it binary-copies the file.
# If the source file has no UTF-8 BOM, PowerShell 5.1 on the guest reads it as
# Windows-1252, misinterpreting multi-byte UTF-8 sequences (e.g. em dash U+2014
@@ -374,7 +374,7 @@ try {
[int64]$remoteSize -ge ([int64]$hostSize - 6) -and [int64]$remoteSize -le ([int64]$hostSize + 6)
}
# ── Build argument list for Setup-WinBuild2025.ps1 ───────────────────────
# ── Build argument list for Install-CIToolchain-WinBuild2025.ps1 ───────────────────────
$setupArgs = @{
BuildPassword = $BuildPassword
BuildUsername = $BuildUsername
@@ -392,7 +392,7 @@ try {
if ($SkipCleanup) { $setupArgs['SkipCleanup'] = $true }
if ($SkipTier2) { $setupArgs['SkipTier2'] = $true }
# ── Run Setup-WinBuild2025.ps1 inside the VM ──────────────────────────────
# ── Run Install-CIToolchain-WinBuild2025.ps1 inside the VM ──────────────────────────────
# Setup may return exit 3010 (ERROR_SUCCESS_REBOOT_REQUIRED) when Windows
# Update applied patches that need a reboot. We loop: reboot guest, wait for
# WinRM, reopen session, re-invoke Setup. Steps 1-5 are idempotent (~30 s);
@@ -441,7 +441,7 @@ try {
return $false
}
Write-Host "[Prepare] Running Setup-WinBuild2025.ps1 inside VM (this will take a while)..."
Write-Host "[Prepare] Running Install-CIToolchain-WinBuild2025.ps1 inside VM (this will take a while)..."
for ($iter = 1; $iter -le $maxWuIterations; $iter++) {
Write-Host "[Prepare] Setup iteration $iter/$maxWuIterations"
@@ -466,7 +466,7 @@ try {
if ($result -eq 0) { break }
if ($result -ne 3010) {
throw "Setup-WinBuild2025.ps1 exited with code $result"
throw "Install-CIToolchain-WinBuild2025.ps1 exited with code $result"
}
# exit 3010 (or transport error treated as 3010) → WU needs reboot.
@@ -721,3 +721,5 @@ finally {
}
Write-Host "[Prepare] Host TrustedHosts restored."
}
+2 -2
View File
@@ -5,8 +5,8 @@
.DESCRIPTION
Connects to the VM via WinRM (HTTP/Basic) and runs all checks that
Setup-WinBuild2025.ps1 Steps 1/2/3/4b/5b/5c assert as validation-only.
Use this after Deploy completes and before running Prepare/Setup.
Install-CIToolchain-WinBuild2025.ps1 Steps 1/2/3/4b/5b/5c assert as validation-only.
Use this after Deploy completes and before running Prepare/Install-CIToolchain.
.PARAMETER VMIPAddress
IP address of the guest VM on VMnet8 (e.g. 192.168.79.129).
+1 -1
View File
@@ -47,7 +47,7 @@ param(
[string] $PythonVersion = '3.13.3',
[switch] $Remediate,
# Skip Tier-2 Toolchain checks (mirrors -SkipTier2 in Setup-WinBuild2025.ps1)
# Skip Tier-2 Toolchain checks (mirrors -SkipTier2 in Install-CIToolchain-WinBuild2025.ps1)
[switch] $SkipTier2
)