generated from MrSphay/codex-agent-repository-kit
51 lines
1.4 KiB
PowerShell
51 lines
1.4 KiB
PowerShell
[CmdletBinding()]
|
|
param(
|
|
[string]$OutputPath = ".\dist\MrTrust.exe"
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
function Resolve-FullPath {
|
|
param([Parameter(Mandatory)][string]$Path)
|
|
|
|
$executionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($Path)
|
|
}
|
|
|
|
$root = Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Path)
|
|
$sourcePath = Join-Path $root "src\MrTrustLauncher.cs"
|
|
$resolvedOutputPath = Resolve-FullPath $OutputPath
|
|
$outputDirectory = Split-Path -Parent $resolvedOutputPath
|
|
|
|
if (-not (Test-Path -LiteralPath $sourcePath)) {
|
|
throw "Launcher source not found: $sourcePath"
|
|
}
|
|
|
|
New-Item -ItemType Directory -Force -Path $outputDirectory | Out-Null
|
|
|
|
$compilerCandidates = @(
|
|
"$env:WINDIR\Microsoft.NET\Framework64\v4.0.30319\csc.exe",
|
|
"$env:WINDIR\Microsoft.NET\Framework\v4.0.30319\csc.exe"
|
|
)
|
|
|
|
$compiler = $compilerCandidates | Where-Object { Test-Path -LiteralPath $_ } | Select-Object -First 1
|
|
if (-not $compiler) {
|
|
throw "csc.exe was not found. Run this build on a Windows Gitea runner with .NET Framework installed."
|
|
}
|
|
|
|
& $compiler `
|
|
/nologo `
|
|
/target:winexe `
|
|
/optimize+ `
|
|
/platform:anycpu `
|
|
/out:$resolvedOutputPath `
|
|
/reference:System.Windows.Forms.dll `
|
|
/reference:System.Drawing.dll `
|
|
$sourcePath
|
|
|
|
if ($LASTEXITCODE -ne 0) {
|
|
throw "csc.exe failed with exit code $LASTEXITCODE."
|
|
}
|
|
|
|
Write-Host "Created EXE:"
|
|
Write-Host " $resolvedOutputPath"
|