fix(template): Add 7-Zip to machine PATH registry (not just session PATH)

Root cause: Assert-Step 'Final' 'dotnet/python/msbuild' block contains a
registry PATH refresh that overwrites $env:PATH, discarding the temporary
session injection added in §6.6. Next assertion (7z command available) then fails.

Fix: use SetEnvironmentVariable('PATH', ..., 'Machine') to permanently register
C:\Program Files\7-Zip in the system PATH — same pattern used for dotnet and MSBuild.
Follow-up registry refresh ensures $env:PATH is also current.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Simone
2026-05-10 21:50:48 +02:00
parent 0fd931d6a9
commit e2f1f8b1ea
+7 -3
View File
@@ -1079,10 +1079,14 @@ if (Test-Path $sevenZipExe) {
Write-Host "7-Zip installed." Write-Host "7-Zip installed."
} }
# 7-Zip MSI does NOT add to system PATH — inject directory directly # 7-Zip MSI does NOT add to system PATH — register permanently in Machine PATH
if ($env:PATH -notlike "*$sevenZipDir*") { $machinePath = [System.Environment]::GetEnvironmentVariable('PATH', 'Machine')
$env:PATH = $env:PATH + ";$sevenZipDir" if ($machinePath -notlike "*$sevenZipDir*") {
[System.Environment]::SetEnvironmentVariable(
'PATH', "$machinePath;$sevenZipDir", 'Machine')
} }
$env:PATH = [System.Environment]::GetEnvironmentVariable('PATH', 'Machine') + ';' +
[System.Environment]::GetEnvironmentVariable('PATH', 'User')
# Validation # Validation
Assert-Step '7-Zip' '7z.exe exists at expected path' { Assert-Step '7-Zip' '7z.exe exists at expected path' {