$ErrorActionPreference='Stop' $compiler=Join-Path $env:WINDIR 'Microsoft.NET/Framework64/v4.0.30319/csc.exe' if (!(Test-Path -LiteralPath $compiler)) { throw '.NET Framework C# compiler not found.' } Push-Location $PSScriptRoot try { & $compiler /nologo /target:winexe /platform:anycpu /codepage:65001 /reference:System.Windows.Forms.dll /reference:System.Drawing.dll /out:YD-App-Packager.exe Packager.cs if ($LASTEXITCODE -ne 0) { throw 'Packager compilation failed.' } } finally { Pop-Location }