| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- Set-StrictMode -Version Latest
- $ErrorActionPreference = "Stop"
- $repoRoot = Split-Path -Parent $MyInvocation.MyCommand.Path
- $windowsDir = Join-Path $repoRoot "windows"
- $serverDir = Join-Path $repoRoot "server"
- $windowsProject = Join-Path $windowsDir "NetworkTool.Client\NetworkTool.Client.csproj"
- $windowsPublishOutput = Join-Path $repoRoot "publish\win-x64"
- $serverLinuxOutput = Join-Path $serverDir "networktool-server-linux-amd64"
- if (-not (Test-Path -LiteralPath $windowsProject)) {
- throw "Windows project not found: $windowsProject"
- }
- if (-not (Test-Path -LiteralPath $serverDir)) {
- throw "Server directory not found: $serverDir"
- }
- Write-Host "[1/2] Publishing Windows client (Release, self-contained win-x64)..."
- dotnet publish $windowsProject `
- -c Release `
- -r win-x64 `
- --self-contained true `
- -p:PublishSingleFile=true `
- -p:IncludeNativeLibrariesForSelfExtract=true `
- -p:EnableCompressionInSingleFile=true `
- -o $windowsPublishOutput
- $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: publish/win-x64/"
- Write-Host "Server Linux output: server/networktool-server-linux-amd64"
|