实现 .NET 10 托盘版网关保活
包含分层探测、可补偿的 IPv4 路由/DNS 切换、自动策略、托盘与分组设置界面、只读诊断工具、离线测试和发布脚本。
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
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
|
||||
Reference in New Issue
Block a user