54 lines
1.4 KiB
PowerShell
54 lines
1.4 KiB
PowerShell
param(
|
|
[string]$OutputDir = "runs/msglib-sidecar",
|
|
[string]$Configuration = "Release"
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
$repo = Resolve-Path -LiteralPath (Join-Path $PSScriptRoot "..")
|
|
$sourceDir = Join-Path $repo "native/MsgLibReadSidecar"
|
|
$outDirPath = Join-Path $repo $OutputDir
|
|
$outExe = Join-Path $outDirPath "MsgLibReadSidecar.exe"
|
|
|
|
if (-not (Test-Path -LiteralPath $sourceDir)) {
|
|
throw "source directory not found: $sourceDir"
|
|
}
|
|
|
|
$csc = "$env:WINDIR\Microsoft.NET\Framework\v4.0.30319\csc.exe"
|
|
if (-not (Test-Path -LiteralPath $csc)) {
|
|
throw "32-bit .NET Framework csc.exe v4.0.30319 not found"
|
|
}
|
|
|
|
New-Item -ItemType Directory -Force -Path $outDirPath | Out-Null
|
|
|
|
$sources = Get-ChildItem -LiteralPath $sourceDir -Filter '*.cs' | Sort-Object Name | ForEach-Object { $_.FullName }
|
|
if (-not $sources) {
|
|
throw "no C# sources found in $sourceDir"
|
|
}
|
|
|
|
& $csc `
|
|
/nologo `
|
|
/target:exe `
|
|
/platform:x86 `
|
|
/optimize+ `
|
|
/warn:0 `
|
|
/out:$outExe `
|
|
/reference:System.dll `
|
|
/reference:System.Core.dll `
|
|
/reference:System.Data.dll `
|
|
/reference:System.Web.Extensions.dll `
|
|
$sources
|
|
|
|
if ($LASTEXITCODE -ne 0) {
|
|
throw "MsgLib sidecar compilation failed with exit code $LASTEXITCODE"
|
|
}
|
|
|
|
[ordered]@{
|
|
ok = $true
|
|
configuration = $Configuration
|
|
platform = "x86"
|
|
csc = $csc
|
|
source_dir = $sourceDir
|
|
output = $outExe
|
|
} | ConvertTo-Json -Depth 4 -Compress
|