farmcontrol-server/scripts/build-windows-nsis.ps1
Tom Butcher 6f3c312f6d
Some checks failed
farmcontrol/farmcontrol-server/pipeline/head There was a failure building this commit
Implement NSIS installer for Farm Control Server and update build scripts
- Added a new NSIS installer script (farmcontrol-server.nsi) for packaging the Farm Control Server on Windows, replacing the previous MSI approach.
- Updated the build process to utilize the new NSIS script, including changes in the finalize-desktop-artifacts.mjs to reflect the new installer format.
- Removed the obsolete MSI build script (build-windows-msi.ps1) and related files to streamline the packaging process.
- Updated the README to reflect changes in the post-package process for Windows installers.
2026-08-01 21:30:11 +01:00

93 lines
2.7 KiB
PowerShell

param(
[Parameter(Mandatory = $true)]
[string]$SetupExe,
[Parameter(Mandatory = $true)]
[string]$SetupArchive,
[Parameter(Mandatory = $true)]
[string]$SetupMetadata,
[Parameter(Mandatory = $true)]
[string]$OutputExe,
[Parameter(Mandatory = $true)]
[string]$Version
)
$ErrorActionPreference = "Stop"
function Find-Makensis() {
$command = Get-Command makensis -ErrorAction SilentlyContinue
if ($command) {
return $command.Source
}
$searchRoots = @(
"${env:ProgramFiles(x86)}\NSIS\makensis.exe",
"${env:ProgramFiles}\NSIS\makensis.exe"
)
foreach ($candidate in $searchRoots) {
if (Test-Path $candidate) {
return $candidate
}
}
throw "Could not find makensis. Install NSIS 3.x on the Windows build agent."
}
$rootDir = Split-Path -Parent $PSScriptRoot
$nsiPath = Join-Path $rootDir "packaging/windows/farmcontrol-server.nsi"
$installerInclude = Join-Path $rootDir "packaging/windows/installer.nsh"
$workDir = Join-Path $env:TEMP "farmcontrol-server-nsis"
if (Test-Path $workDir) {
Remove-Item $workDir -Recurse -Force
}
New-Item -ItemType Directory -Path $workDir | Out-Null
$setupExePath = (Resolve-Path -LiteralPath $SetupExe).Path
$setupArchivePath = (Resolve-Path -LiteralPath $SetupArchive).Path
$setupMetadataPath = (Resolve-Path -LiteralPath $SetupMetadata).Path
$setupExeName = Split-Path $setupExePath -Leaf
$setupArchiveName = Split-Path $setupArchivePath -Leaf
$setupMetadataName = Split-Path $setupMetadataPath -Leaf
Copy-Item -LiteralPath $setupExePath -Destination (Join-Path $workDir $setupExeName)
Copy-Item -LiteralPath $setupArchivePath -Destination (Join-Path $workDir $setupArchiveName)
Copy-Item -LiteralPath $setupMetadataPath -Destination (Join-Path $workDir $setupMetadataName)
Copy-Item -LiteralPath $nsiPath -Destination (Join-Path $workDir "farmcontrol-server.nsi")
Copy-Item -LiteralPath $installerInclude -Destination (Join-Path $workDir "installer.nsh")
$makensis = Find-Makensis
$outputExePath = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($OutputExe)
$outputDir = Split-Path $outputExePath -Parent
if (-not (Test-Path $outputDir)) {
New-Item -ItemType Directory -Path $outputDir | Out-Null
}
$makensisArgs = @(
"/NOCD"
"/DOUTFILE=$outputExePath"
"/DVERSION=$Version"
"/DSETUP_EXE_NAME=$setupExeName"
"/DSETUP_ARCHIVE_NAME=$setupArchiveName"
"/DSETUP_METADATA_NAME=$setupMetadataName"
(Join-Path $workDir "farmcontrol-server.nsi")
)
Push-Location $workDir
try {
& $makensis @makensisArgs
} finally {
Pop-Location
}
if (-not (Test-Path $outputExePath)) {
throw "NSIS installer was not created at $outputExePath"
}
Write-Host "Created NSIS installer at $outputExePath"