Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build-iso.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Requires -RunAsAdministrator
#Requires -RunAsAdministrator

<#
.SYNOPSIS
Expand Down
13 changes: 13 additions & 0 deletions tests/BuildIso.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,19 @@ Describe "build-iso.ps1 static checks" {
It "does not reference MountDir anymore" {
$scriptContent.Contains('$MountDir') | Should -Be $false
}

It "preserves the main try block when Windows PowerShell 5.1 reads the file" {
& powershell.exe -NoProfile -Command {
param($path)
$errors = $null
$ast = [System.Management.Automation.Language.Parser]::ParseFile($path, [ref]$null, [ref]$errors)
$main = @($ast.EndBlock.Statements | Where-Object { $_ -is [System.Management.Automation.Language.TryStatementAst] })
if ($errors.Count -gt 0 -or $main.Count -ne 1 -or $main[0].CatchClauses.Count -ne 1 -or -not $main[0].Finally) {
throw 'Windows PowerShell cannot read the ISO builder main try/catch/finally block.'
}
} -args $scriptPath
$LASTEXITCODE | Should -Be 0
}
}

Describe "ISO payload selection" {
Expand Down
Loading