28 lines
2.4 KiB
PowerShell
28 lines
2.4 KiB
PowerShell
param([switch]$SelfContained)
|
|
$ErrorActionPreference = 'Stop'
|
|
$root = Split-Path -Parent $PSScriptRoot
|
|
$dotnet = Join-Path $env:USERPROFILE '.dotnet-sdk\dotnet.exe'
|
|
$flavor = if ($SelfContained) { 'standalone' } else { 'runtime-dependent' }
|
|
$out = Join-Path $root "artifacts\publish\$flavor"
|
|
$env:DOTNET_ROOT = Split-Path -Parent $dotnet
|
|
& $dotnet publish (Join-Path $root 'src\GatewayKeepalive.Tray\GatewayKeepalive.Tray.csproj') -c Release -r win-x64 --self-contained $SelfContained -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true -p:DebugType=embedded -o $out | Select-Object -Last 2
|
|
if ($LASTEXITCODE -ne 0) { throw 'publish failed' }
|
|
& $dotnet publish (Join-Path $root 'src\GatewayKeepalive.Cli\GatewayKeepalive.Cli.csproj') -c Release -r win-x64 --self-contained $SelfContained -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true -p:DebugType=embedded -o (Join-Path $out 'diagnostics') | Select-Object -Last 2
|
|
if ($LASTEXITCODE -ne 0) { throw 'cli publish failed' }
|
|
$preview = Join-Path $root "artifacts\preview-$flavor"
|
|
Remove-Item -LiteralPath $preview -Recurse -Force -ErrorAction SilentlyContinue
|
|
$stderr = Join-Path $root "artifacts\$flavor-stderr.txt"
|
|
# Arguments containing spaces must be quoted explicitly; Start-Process does not escape them.
|
|
$process = Start-Process -FilePath (Join-Path $out 'GatewayKeepalive.exe') -ArgumentList @('--preview', ('"' + $preview + '"')) -WindowStyle Hidden -PassThru -Wait -RedirectStandardError $stderr
|
|
$pngs = @(Get-ChildItem -LiteralPath $preview -Filter '*.png' -ErrorAction SilentlyContinue).Count
|
|
$report = Join-Path $root "artifacts\$flavor-diagnostics.json"
|
|
& (Join-Path $out 'diagnostics\GatewayKeepalive.Cli.exe') --diagnose --output $report | Out-Null
|
|
$cliExit = $LASTEXITCODE
|
|
$diagnostics = Get-Content -LiteralPath $report -Raw | ConvertFrom-Json
|
|
$guiError = ''
|
|
if (Test-Path -LiteralPath $stderr) {
|
|
$rawError = Get-Content -LiteralPath $stderr -Raw -ErrorAction SilentlyContinue
|
|
if ($null -ne $rawError) { $guiError = $rawError.Trim() }
|
|
}
|
|
[pscustomobject]@{ Flavor = $flavor; GuiExit = $process.ExitCode; PreviewPngs = $pngs; GuiStderr = $guiError; CliExit = $cliExit; ReadOnly = $diagnostics.ReadOnly; Gateway = $diagnostics.BestRoute.Gateway; Interface = $diagnostics.BestRoute.InterfaceIndex; Files = @(Get-ChildItem -LiteralPath $out -File | Select-Object Name, Length) } | ConvertTo-Json -Depth 4
|