56 lines
2.9 KiB
PowerShell
56 lines
2.9 KiB
PowerShell
param(
|
|
[string]$Configuration = "Release"
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
$repoRoot = Split-Path -Parent $PSScriptRoot
|
|
$installerRoot = Join-Path $repoRoot "installer"
|
|
$artifactsRoot = Join-Path $repoRoot "artifacts"
|
|
$packageRoot = Join-Path $artifactsRoot "server-installer-payload"
|
|
$bootstrapperProject = Join-Path $repoRoot "installer\AttackTracerNinjaServerBootstrapper\AttackTracerNinjaServerBootstrapper.csproj"
|
|
$bootstrapperPayload = Join-Path $repoRoot "installer\AttackTracerNinjaServerBootstrapper\payload.zip"
|
|
$bootstrapperPublish = Join-Path $artifactsRoot "server-bootstrapper\win-x64"
|
|
$outputExe = Join-Path $artifactsRoot "AttackTracerNinjaServerSetup.exe"
|
|
$version = "1.0.9"
|
|
|
|
Write-Host "Publishing AttackTracerNinjaServer version $version"
|
|
|
|
if (Test-Path $packageRoot) { Remove-Item -LiteralPath $packageRoot -Recurse -Force }
|
|
if (Test-Path $bootstrapperPublish) { Remove-Item -LiteralPath $bootstrapperPublish -Recurse -Force }
|
|
if (Test-Path $bootstrapperPayload) { Remove-Item -LiteralPath $bootstrapperPayload -Force }
|
|
if (Test-Path $outputExe) { Remove-Item -LiteralPath $outputExe -Force }
|
|
New-Item -ItemType Directory -Force -Path $packageRoot, $bootstrapperPublish | Out-Null
|
|
|
|
Copy-Item -Path (Join-Path $repoRoot "config\attacktracer-server-settings.example.json") -Destination (Join-Path $packageRoot "attacktracer-server-settings.example.json") -Force
|
|
Copy-Item -Path (Join-Path $installerRoot "server-install-attacktracer-ninja-server.ps1") -Destination (Join-Path $packageRoot "install-attacktracer-ninja-server.ps1") -Force
|
|
Copy-Item -Path (Join-Path $installerRoot "server-uninstall-attacktracer-ninja-server.ps1") -Destination (Join-Path $packageRoot "uninstall-attacktracer-ninja-server.ps1") -Force
|
|
Copy-Item -Path (Join-Path $installerRoot "runtime-build-attacktracer-org-report.ps1") -Destination (Join-Path $packageRoot "build-attacktracer-org-report.ps1") -Force
|
|
Copy-Item -Path (Join-Path $installerRoot "runtime-run-attacktracer-ninja-server.ps1") -Destination (Join-Path $packageRoot "run-attacktracer-ninja-server.ps1") -Force
|
|
Set-Content -Path (Join-Path $packageRoot "VERSION.txt") -Value $version -NoNewline
|
|
|
|
Write-Host "Creating embedded payload zip"
|
|
Compress-Archive -Path (Join-Path $packageRoot "*") -DestinationPath $bootstrapperPayload -CompressionLevel Optimal -Force
|
|
|
|
Write-Host "Publishing server bootstrapper installer"
|
|
& dotnet restore $bootstrapperProject -r win-x64
|
|
if ($LASTEXITCODE -ne 0) {
|
|
throw "Bootstrapper restore failed"
|
|
}
|
|
|
|
& dotnet publish $bootstrapperProject `
|
|
-c $Configuration `
|
|
-r win-x64 `
|
|
--self-contained true `
|
|
-p:PublishSingleFile=true `
|
|
-p:IncludeNativeLibrariesForSelfExtract=true `
|
|
-o $bootstrapperPublish
|
|
|
|
if ($LASTEXITCODE -ne 0) {
|
|
throw "Bootstrapper publish failed"
|
|
}
|
|
|
|
Copy-Item -Path (Join-Path $bootstrapperPublish "AttackTracerNinjaServerBootstrapper.exe") -Destination $outputExe -Force
|
|
|
|
Write-Host "Server installer created at $outputExe"
|