914072fdd8
Replace all references to CI-WinBuild.vmx with WinBuild2025.vmx. Update template path: F:\CI\Templates\WinBuild\ → F:\CI\Templates\WinBuild2025\ Files affected: - runner/config.yaml: GITEA_CI_TEMPLATE_PATH env var - docs: HOST-SETUP.md, WINDOWS-TEMPLATE-SETUP.md, TEST-PLAN, RUNBOOK - scripts: Measure-CIBenchmark, Set-TemplateSharedFolders, Test-NsinnounpBuild - TODO.md, Setup-Host.ps1, README.md Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
119 lines
4.8 KiB
PowerShell
119 lines
4.8 KiB
PowerShell
#Requires -Version 5.1
|
|
<#
|
|
.SYNOPSIS
|
|
Configures VMware shared folder entries in the CI template VMX for build cache sharing.
|
|
|
|
.DESCRIPTION
|
|
Adds two shared folder mappings to the template VM's .vmx file:
|
|
nuget-cache host: F:\CI\Cache\NuGet guest: \\vmware-host\Shared Folders\nuget-cache
|
|
pip-cache host: F:\CI\Cache\pip guest: \\vmware-host\Shared Folders\pip-cache
|
|
|
|
These UNC paths are used by Invoke-RemoteBuild.ps1 -UseSharedCache to redirect
|
|
dotnet's NuGet package store and pip's download cache to persistent host-side
|
|
directories, avoiding repeat downloads across builds.
|
|
|
|
The script is idempotent: existing sharedFolder.* lines are removed before
|
|
the new block is written. A .bak copy of the original VMX is kept alongside it.
|
|
|
|
Prerequisites:
|
|
- Template VM must NOT be running when this script runs.
|
|
- VMware Tools (HGFS driver) must be installed in the template guest.
|
|
- Run once; all subsequent linked clones inherit the shared folder config.
|
|
|
|
After running: use Invoke-RemoteBuild.ps1 -UseSharedCache on builds that
|
|
target VMs cloned from this updated template.
|
|
|
|
.PARAMETER TemplatePath
|
|
Full path to the template VM's .vmx file.
|
|
Default: F:\CI\Templates\WinBuild2025\WinBuild2025.vmx
|
|
|
|
.PARAMETER NuGetCacheDir
|
|
Host-side path for the NuGet package cache directory.
|
|
Default: F:\CI\Cache\NuGet
|
|
|
|
.PARAMETER PipCacheDir
|
|
Host-side path for the pip download cache directory.
|
|
Default: F:\CI\Cache\pip
|
|
|
|
.EXAMPLE
|
|
# Configure template (run from elevated PowerShell — template must be stopped)
|
|
.\Set-TemplateSharedFolders.ps1
|
|
|
|
# Preview changes without modifying files
|
|
.\Set-TemplateSharedFolders.ps1 -WhatIf
|
|
#>
|
|
[CmdletBinding(SupportsShouldProcess)]
|
|
param(
|
|
[string] $TemplatePath = 'F:\CI\Templates\WinBuild2025\WinBuild2025.vmx',
|
|
[string] $NuGetCacheDir = 'F:\CI\Cache\NuGet',
|
|
[string] $PipCacheDir = 'F:\CI\Cache\pip'
|
|
)
|
|
|
|
Set-StrictMode -Version Latest
|
|
$ErrorActionPreference = 'Stop'
|
|
|
|
if (-not (Test-Path $TemplatePath -PathType Leaf)) {
|
|
throw "Template VMX not found: $TemplatePath"
|
|
}
|
|
|
|
# ── Step 1: Ensure host cache directories exist ───────────────────────────────
|
|
foreach ($dir in @($NuGetCacheDir, $PipCacheDir)) {
|
|
if (-not (Test-Path $dir)) {
|
|
if ($PSCmdlet.ShouldProcess($dir, 'Create host cache directory')) {
|
|
New-Item -ItemType Directory -Path $dir -Force | Out-Null
|
|
Write-Host "[SharedFolders] Created host cache dir: $dir"
|
|
}
|
|
} else {
|
|
Write-Host "[SharedFolders] Host cache dir exists: $dir"
|
|
}
|
|
}
|
|
|
|
# ── Step 2: Read VMX, strip existing sharedFolder + HGFS lines ───────────────
|
|
$lines = [System.IO.File]::ReadAllLines($TemplatePath, [System.Text.Encoding]::UTF8)
|
|
$stripped = $lines | Where-Object {
|
|
$_ -notmatch '^sharedFolder' -and
|
|
$_ -notmatch '^isolation\.tools\.hgfs\.disable'
|
|
}
|
|
|
|
# ── Step 3: Build replacement sharedFolder block ──────────────────────────────
|
|
# VMX hostPath requires double-escaped backslashes
|
|
$nugetEsc = $NuGetCacheDir.Replace('\', '\\')
|
|
$pipEsc = $PipCacheDir.Replace('\', '\\')
|
|
|
|
$sharedBlock = @(
|
|
'sharedFolder.maxNum = "2"'
|
|
'sharedFolder0.present = "TRUE"'
|
|
'sharedFolder0.enabled = "TRUE"'
|
|
'sharedFolder0.readAccess = "TRUE"'
|
|
'sharedFolder0.writeAccess = "TRUE"'
|
|
"sharedFolder0.hostPath = `"$nugetEsc`""
|
|
'sharedFolder0.guestName = "nuget-cache"'
|
|
'sharedFolder0.expiration = "never"'
|
|
'sharedFolder1.present = "TRUE"'
|
|
'sharedFolder1.enabled = "TRUE"'
|
|
'sharedFolder1.readAccess = "TRUE"'
|
|
'sharedFolder1.writeAccess = "TRUE"'
|
|
"sharedFolder1.hostPath = `"$pipEsc`""
|
|
'sharedFolder1.guestName = "pip-cache"'
|
|
'sharedFolder1.expiration = "never"'
|
|
'isolation.tools.hgfs.disable = "FALSE"'
|
|
)
|
|
|
|
$newLines = @($stripped) + $sharedBlock
|
|
|
|
# ── Step 4: Backup and write VMX ─────────────────────────────────────────────
|
|
if ($PSCmdlet.ShouldProcess($TemplatePath, 'Write updated VMX with shared folder entries')) {
|
|
$backupPath = "$TemplatePath.bak"
|
|
Copy-Item $TemplatePath $backupPath -Force
|
|
Write-Host "[SharedFolders] Original backed up: $backupPath"
|
|
|
|
[System.IO.File]::WriteAllLines($TemplatePath, $newLines, [System.Text.Encoding]::UTF8)
|
|
|
|
Write-Host "[SharedFolders] VMX updated: $TemplatePath"
|
|
Write-Host "[SharedFolders] Mappings:"
|
|
Write-Host " nuget-cache $NuGetCacheDir -> \\vmware-host\Shared Folders\nuget-cache"
|
|
Write-Host " pip-cache $PipCacheDir -> \\vmware-host\Shared Folders\pip-cache"
|
|
Write-Host "[SharedFolders] Next: run Invoke-RemoteBuild.ps1 -UseSharedCache to activate."
|
|
}
|
|
|