$ErrorActionPreference = "Stop" $repoRoot = Split-Path -Parent $PSScriptRoot Push-Location $repoRoot try { rustup target add x86_64-unknown-linux-musl cargo build --release --no-default-features --target x86_64-unknown-linux-musl --bin cold_water_server if ($LASTEXITCODE -ne 0) { throw "Linux musl build failed with exit code $LASTEXITCODE" } $distDir = Join-Path $repoRoot "dist\linux" New-Item -ItemType Directory -Force -Path $distDir | Out-Null $binSrc = Join-Path $repoRoot "target\x86_64-unknown-linux-musl\release\cold_water_server" $binDst = Join-Path $distDir "cold_water_server" Copy-Item -Force $binSrc $binDst $cfgSrc = Join-Path $repoRoot "server_config.json" $cfgDst = Join-Path $distDir "server_config.json" if (Test-Path $cfgSrc) { Copy-Item -Force $cfgSrc $cfgDst } $modsSrc = Join-Path $repoRoot "mods" $modsDst = Join-Path $distDir "mods" if (Test-Path $modsSrc) { if (Test-Path $modsDst) { Remove-Item -Recurse -Force $modsDst } Copy-Item -Recurse -Force $modsSrc $modsDst } Write-Host "Packaged Linux server bundle at $distDir" } finally { Pop-Location }