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:
@@ -1079,10 +1079,14 @@ if (Test-Path $sevenZipExe) {
|
||||
Write-Host "7-Zip installed."
|
||||
}
|
||||
|
||||
# 7-Zip MSI does NOT add to system PATH — inject directory directly
|
||||
if ($env:PATH -notlike "*$sevenZipDir*") {
|
||||
$env:PATH = $env:PATH + ";$sevenZipDir"
|
||||
# 7-Zip MSI does NOT add to system PATH — register permanently in Machine PATH
|
||||
$machinePath = [System.Environment]::GetEnvironmentVariable('PATH', 'Machine')
|
||||
if ($machinePath -notlike "*$sevenZipDir*") {
|
||||
[System.Environment]::SetEnvironmentVariable(
|
||||
'PATH', "$machinePath;$sevenZipDir", 'Machine')
|
||||
}
|
||||
$env:PATH = [System.Environment]::GetEnvironmentVariable('PATH', 'Machine') + ';' +
|
||||
[System.Environment]::GetEnvironmentVariable('PATH', 'User')
|
||||
|
||||
# Validation
|
||||
Assert-Step '7-Zip' '7z.exe exists at expected path' {
|
||||
|
||||
Reference in New Issue
Block a user