[CmdletBinding()] param([switch]$SkipTests) $ErrorActionPreference = 'Stop' $compiler = Join-Path $env:WINDIR 'Microsoft.NET\Framework64\v4.0.30319\csc.exe' if (!(Test-Path -LiteralPath $compiler)) { throw 'The .NET Framework 4 C# compiler is required.' } $outputDir = Join-Path $PSScriptRoot 'build' New-Item -ItemType Directory -Force -Path $outputDir | Out-Null $sources = @(Get-ChildItem -LiteralPath (Join-Path $PSScriptRoot 'src') -Filter '*.cs' | ForEach-Object FullName) $sources += Join-Path $PSScriptRoot 'tests\SelfTests.cs' & $compiler /nologo /warnaserror+ /optimize+ /target:exe /platform:anycpu "/out:$outputDir\HomeVisionPower.exe" /reference:System.ServiceProcess.dll /reference:System.Web.Extensions.dll /reference:System.Security.dll $sources if ($LASTEXITCODE -ne 0) { throw 'Compilation failed.' } if (!$SkipTests) { & (Join-Path $outputDir 'HomeVisionPower.exe') --self-test if ($LASTEXITCODE -ne 0) { throw 'Self-tests failed.' } } Write-Output "Built $outputDir\HomeVisionPower.exe"