Set-StrictMode -Version Latest $ErrorActionPreference = "Stop" $repoRoot = Split-Path -Parent $MyInvocation.MyCommand.Path $windowsDir = Join-Path $repoRoot "windows" $serverDir = Join-Path $repoRoot "server" $windowsSolution = Join-Path $windowsDir "NetworkTool.Client.sln" $serverLinuxOutput = Join-Path $serverDir "networktool-server-linux-amd64" if (-not (Test-Path -LiteralPath $windowsSolution)) { throw "Windows solution not found: $windowsSolution" } if (-not (Test-Path -LiteralPath $serverDir)) { throw "Server directory not found: $serverDir" } Write-Host "[1/2] Building Windows client (Debug)..." dotnet build $windowsSolution -c Debug $previousGoos = $env:GOOS $previousGoarch = $env:GOARCH $previousCgoEnabled = $env:CGO_ENABLED try { Write-Host "[2/2] Building server for Linux amd64..." Set-Location -LiteralPath $serverDir $env:GOOS = "linux" $env:GOARCH = "amd64" $env:CGO_ENABLED = "0" go build -o $serverLinuxOutput ./cmd/networktool-server } finally { $env:GOOS = $previousGoos $env:GOARCH = $previousGoarch $env:CGO_ENABLED = $previousCgoEnabled Set-Location -LiteralPath $repoRoot } Write-Host "Build completed." Write-Host "Windows client output: windows/NetworkTool.Client/bin/Debug/net9.0-windows/" Write-Host "Server Linux output: server/networktool-server-linux-amd64"