refactor(template): rename Setup-TemplateVM.ps1 -> Setup-WinBuild2025.ps1

- git mv Setup-TemplateVM.ps1 Setup-WinBuild2025.ps1
- git mv Prepare-TemplateSetup.ps1 -> Prepare-WinBuild2025.ps1 (name already in place)
- Updated all references across the workspace:
    template/Prepare-WinBuild2025.ps1 (script copy, assertions, comments)
    template/Setup-WinBuild2025.ps1 (self-references in docblock and final message)
    README.md (directory tree)
    TODO.md (all inline links and task descriptions)
    docs/WINDOWS-TEMPLATE-SETUP.md (table, step descriptions, phase header, troubleshooting)
    docs/LINUX-TEMPLATE-SETUP.md (Windows equivalent reference)
This commit is contained in:
Simone
2026-05-09 23:28:36 +02:00
parent 0f21e61668
commit 644258f59c
6 changed files with 60 additions and 60 deletions
@@ -1,7 +1,7 @@
#Requires -Version 5.1
<#
.SYNOPSIS
HOST-side script: delivers and runs Setup-TemplateVM.ps1 inside the template VM.
HOST-side script: delivers and runs Setup-WinBuild2025.ps1 inside the template VM.
.DESCRIPTION
Automates the template VM provisioning from the host machine:
@@ -11,8 +11,8 @@
4. Tests WinRM connectivity (Test-WSMan) fails fast with actionable message
5. Opens PSSession to the VM
6. Ensures C:\CI exists on guest; validates creation
7. Copies Setup-TemplateVM.ps1 into the VM; validates file present + size match
8. Runs Setup-TemplateVM.ps1 inside the VM with the given parameters
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
(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
@@ -67,13 +67,13 @@
.PARAMETER BuildUsername
Local username for the CI build account inside the VM. Default: ci_build.
Passed through to Setup-TemplateVM.ps1 and used in post-setup validation.
Passed through to Setup-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-TemplateVM.ps1 to skip the Windows Update step.
Pass through to Setup-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).
@@ -94,21 +94,21 @@
.EXAMPLE
# Fully automated — VMX path only (power-on + IP detection + snapshot automatic):
.\Prepare-TemplateSetup.ps1 `
.\Prepare-WinBuild2025.ps1 `
-VMXPath 'F:\CI\Templates\WinBuild\WinBuild.vmx' `
-BuildPassword 'StrongCIPass!2026' -StoreCredential
# Skip Windows Update (already applied):
.\Prepare-TemplateSetup.ps1 `
.\Prepare-WinBuild2025.ps1 `
-VMXPath 'F:\CI\Templates\WinBuild\WinBuild.vmx' `
-SkipWindowsUpdate -StoreCredential
# Explicit IP (manual start, no VMware Tools required for IP detection):
.\Prepare-TemplateSetup.ps1 -VMIPAddress 192.168.79.130 `
.\Prepare-WinBuild2025.ps1 -VMIPAddress 192.168.79.130 `
-BuildPassword 'StrongCIPass!2026' -StoreCredential
# Both supplied — uses VMXPath for power-on/snapshot, explicit IP skips getGuestIPAddress:
.\Prepare-TemplateSetup.ps1 `
.\Prepare-WinBuild2025.ps1 `
-VMXPath 'F:\CI\Templates\WinBuild\WinBuild.vmx' -VMIPAddress 192.168.79.130 `
-BuildPassword 'StrongCIPass!2026' -StoreCredential
#>
@@ -217,8 +217,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-TemplateVM.ps1 present alongside this script' {
Test-Path (Join-Path $scriptDir 'Setup-TemplateVM.ps1') -PathType Leaf
Assert-Step 'PreFlight' 'Setup-WinBuild2025.ps1 present alongside this script' {
Test-Path (Join-Path $scriptDir 'Setup-WinBuild2025.ps1') -PathType Leaf
}
Assert-Step 'PreFlight' "VMIPAddress octets in 0..255" {
$parts = $VMIPAddress.Split('.') | ForEach-Object { [int]$_ }
@@ -331,9 +331,9 @@ $session = New-PSSession `
-ErrorAction Stop
try {
# ── Copy Setup-TemplateVM.ps1 into the VM ─────────────────────────────────
$setupScript = Join-Path $scriptDir 'Setup-TemplateVM.ps1'
$guestScriptPath = 'C:\CI\Setup-TemplateVM.ps1'
# ── Copy Setup-WinBuild2025.ps1 into the VM ───────────────────────────────
$setupScript = Join-Path $scriptDir 'Setup-WinBuild2025.ps1'
$guestScriptPath = 'C:\CI\Setup-WinBuild2025.ps1'
Write-Host "[Prepare] Ensuring C:\CI exists on guest..."
Invoke-Command -Session $session -ScriptBlock {
@@ -345,7 +345,7 @@ try {
Invoke-Command -Session $session -ScriptBlock { Test-Path 'C:\CI' -PathType Container }
}
Write-Host "[Prepare] Copying Setup-TemplateVM.ps1 -> guest $guestScriptPath (UTF-8 BOM)..."
Write-Host "[Prepare] Copying Setup-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
@@ -375,7 +375,7 @@ try {
[int64]$remoteSize -ge ([int64]$hostSize - 6) -and [int64]$remoteSize -le ([int64]$hostSize + 6)
}
# ── Build argument list for Setup-TemplateVM.ps1 ─────────────────────────
# ── Build argument list for Setup-WinBuild2025.ps1 ───────────────────────
$setupArgs = @{
BuildPassword = $BuildPassword
BuildUsername = $BuildUsername
@@ -384,8 +384,8 @@ try {
if ($SkipWindowsUpdate) { $setupArgs['SkipWindowsUpdate'] = $true }
if ($SkipCleanup) { $setupArgs['SkipCleanup'] = $true }
# ── Run Setup-TemplateVM.ps1 inside the VM ────────────────────────────────
Write-Host "[Prepare] Running Setup-TemplateVM.ps1 inside VM (this will take a while)..."
# ── Run Setup-WinBuild2025.ps1 inside the VM ──────────────────────────────
Write-Host "[Prepare] Running Setup-WinBuild2025.ps1 inside VM (this will take a while)..."
Write-Host "[Prepare] Output from guest:"
Write-Host "------------------------------------------------------------"
@@ -412,7 +412,7 @@ try {
Write-Host ""
Write-Warning "*** REBOOT REQUIRED after Windows Update. ***"
Write-Warning " The VM will reboot. Wait for it to come back up, then run:"
Write-Warning " .\Prepare-TemplateSetup.ps1 -VMIPAddress $VMIPAddress -SkipWindowsUpdate"
Write-Warning " .\Prepare-WinBuild2025.ps1 -VMIPAddress $VMIPAddress -SkipWindowsUpdate"
# Reboot the VM
Write-Host "[Prepare] Sending reboot command to VM..."
@@ -421,7 +421,7 @@ try {
}
if ($result -ne 0) {
throw "Setup-TemplateVM.ps1 exited with code $result"
throw "Setup-WinBuild2025.ps1 exited with code $result"
}
# ── Post-setup remote validation ──────────────────────────────────────────
@@ -598,7 +598,7 @@ try {
}
else {
Write-Host " 3. Store CI credentials on this HOST (run in elevated PowerShell):"
Write-Host " .\Prepare-TemplateSetup.ps1 -VMIPAddress $VMIPAddress -StoreCredential"
Write-Host " .\Prepare-WinBuild2025.ps1 -VMIPAddress $VMIPAddress -StoreCredential"
Write-Host " (or manually:)"
Write-Host " New-StoredCredential -Target '$CredentialTarget' ``"
Write-Host " -UserName '$BuildUsername' -Password '<your-build-password>' ``"
@@ -93,7 +93,7 @@
Local username for the CI build account. Default: ci_build.
.PARAMETER BuildPassword
Password for the build account. Mandatory supplied by Prepare-TemplateSetup.ps1
Password for the build account. Mandatory supplied by Prepare-WinBuild2025.ps1
(which prompts interactively). Store the same value in Windows Credential Manager
on the HOST as target "BuildVMGuest".
@@ -107,10 +107,10 @@
Skip the Windows Update step (useful if updates were already applied).
.NOTES
Invoke via Prepare-TemplateSetup.ps1 from the HOST (recommended), or
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-TemplateVM.ps1 -BuildPassword 'YourPassword'
.\Setup-WinBuild2025.ps1 -BuildPassword 'YourPassword'
#>
[CmdletBinding()]
param(
@@ -118,7 +118,7 @@ param(
[string] $BuildUsername = 'ci_build',
# Password for the build account.
# Must be supplied by the caller (Prepare-TemplateSetup.ps1 prompts interactively).
# Must be supplied by the caller (Prepare-WinBuild2025.ps1 prompts interactively).
# Store the same password in Windows Credential Manager on the HOST as target "BuildVMGuest".
[Parameter(Mandatory)]
[string] $BuildPassword,
@@ -1125,8 +1125,8 @@ Write-Host "All pre-snapshot checks passed." -ForegroundColor Green
# ── Done ──────────────────────────────────────────────────────────────────────
Write-Host ""
Write-Host "Setup-TemplateVM.ps1 complete. All Assert-Step checks passed." -ForegroundColor Green
# Full next-steps banner is printed by Prepare-TemplateSetup.ps1 on the host.
Write-Host "Setup-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 ""