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: 2 additions & 0 deletions dist/platforms/windows/entrypoint.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Get-ChildItem -Path c:\registry-keys -File | ForEach-Object {reg import $_.fulln
# Register the Visual Studio installation so Unity can find it
regsvr32 C:\ProgramData\Microsoft\VisualStudio\Setup\x64\Microsoft.VisualStudio.Setup.Configuration.Native.dll

Get-Process -Name regsvr32 -ErrorAction SilentlyContinue | ForEach-Object { Stop-Process -Id $_.Id -Force }

# Install Visual C++ 2013 Redistributables - Unity fails on some GitHub
# Actions Windows runners without this (see game-ci/cli#65, item 5).
& "c:\steps\install_vcredist13.ps1"
Expand Down
44 changes: 44 additions & 0 deletions scripts/validate-platform-scripts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,51 @@ if command -v pwsh >/dev/null 2>&1; then
else
echo "pwsh not available - skipping member-access check"
fi
echo "== Checking for regsvr32 with no /s and no kill afterwards (PowerShell) =="
# regsvr32 without /s waits on a modal dialog forever, keeping the container
# alive so `docker run` never returns. Tokenised, so each invocation is judged
# on its own: regsvr32.exe counts, `a; b` on one line is two invocations, and a
# /s or a cleanup belonging to one call cannot vouch for another.
if command -v pwsh >/dev/null 2>&1; then
if ! pwsh -NoProfile -Command '
$ErrorActionPreference = "Stop"
$failed = $false
Get-ChildItem -Path "dist/platforms" -Filter "*.ps1" -Recurse | ForEach-Object {
$file = $_.FullName
$err = $null
$tokens = [System.Management.Automation.PSParser]::Tokenize((Get-Content $file -Raw), [ref]$err)
if ($err) { return }

for ($i = 0; $i -lt $tokens.Count; $i++) {
if ($tokens[$i].Type -ne "Command" -or $tokens[$i].Content -notmatch "^regsvr32(\.exe)?$") { continue }

$line = $tokens[$i].StartLine
$silent = $false
for ($j = $i + 1; $j -lt $tokens.Count; $j++) {
if ($tokens[$j].Type -eq "NewLine" -or $tokens[$j].Type -eq "StatementSeparator") { break }
if ($tokens[$j].Content -eq "/s") { $silent = $true; break }
}
if ($silent) { continue }

$namedRegsvr = $false
$cleaned = $false
for ($j = $i + 1; $j -lt $tokens.Count -and $tokens[$j].StartLine -le ($line + 20); $j++) {
if ($tokens[$j].Type -eq "CommandArgument" -and $tokens[$j].Content -match "^regsvr32(\.exe)?$") { $namedRegsvr = $true }
if ($namedRegsvr -and $tokens[$j].Type -eq "Command" -and $tokens[$j].Content -eq "Stop-Process") { $cleaned = $true; break }
}
if ($cleaned) { continue }

Write-Host "FAIL: ${file}:${line} calls $($tokens[$i].Content) without /s and never stops it - it waits on a modal dialog forever and keeps the container alive"
$script:failed = $true
}
}
if ($failed) { exit 1 }
'; then
fail=1
fi
else
echo "pwsh not available - skipping regsvr32 check"
fi
echo
if [ "$fail" -ne 0 ]; then
echo "One or more platform script checks failed - see FAIL lines above."
Expand Down
Loading
Loading