Some checks failed
farmcontrol/farmcontrol-server/pipeline/head There was a failure building this commit
- Updated the farmcontrol-server.wxs file to include SetupArchive and SetupMetadata files for the MSI packaging. - Modified the build-windows-msi.ps1 script to accept new parameters for SetupArchive and SetupMetadata, enhancing the MSI build process. - Refactored the finalize-desktop-artifacts script to find and handle multiple Windows installer files, ensuring proper artifact publication.
96 lines
2.2 KiB
PowerShell
96 lines
2.2 KiB
PowerShell
param(
|
|
[Parameter(Mandatory = $true)]
|
|
[string]$SetupExe,
|
|
|
|
[Parameter(Mandatory = $true)]
|
|
[string]$SetupArchive,
|
|
|
|
[Parameter(Mandatory = $true)]
|
|
[string]$SetupMetadata,
|
|
|
|
[Parameter(Mandatory = $true)]
|
|
[string]$OutputMsi,
|
|
|
|
[Parameter(Mandatory = $true)]
|
|
[string]$Version
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
function Find-WixTool($toolName) {
|
|
$command = Get-Command $toolName -ErrorAction SilentlyContinue
|
|
if ($command) {
|
|
return $command.Source
|
|
}
|
|
|
|
$searchRoots = @(
|
|
"${env:ProgramFiles(x86)}\WiX Toolset v3.14\bin",
|
|
"${env:ProgramFiles(x86)}\WiX Toolset v3.11\bin",
|
|
"${env:ProgramFiles}\WiX Toolset v3.14\bin",
|
|
"${env:ProgramFiles}\WiX Toolset v3.11\bin"
|
|
)
|
|
|
|
foreach ($root in $searchRoots) {
|
|
$candidate = Join-Path $root "$toolName.exe"
|
|
if (Test-Path $candidate) {
|
|
return $candidate
|
|
}
|
|
}
|
|
|
|
throw "Could not find $toolName. Install WiX Toolset v3.11 or v3.14 on the Windows build agent."
|
|
}
|
|
|
|
function ConvertTo-WixVersion([string]$rawVersion) {
|
|
$parts = $rawVersion.Split('.')
|
|
while ($parts.Count -lt 4) {
|
|
$parts += '0'
|
|
}
|
|
return ($parts[0..3] -join '.')
|
|
}
|
|
|
|
$rootDir = Split-Path -Parent $PSScriptRoot
|
|
$wxsPath = Join-Path $rootDir "packaging/windows/farmcontrol-server.wxs"
|
|
$workDir = Join-Path $env:TEMP "farmcontrol-server-msi"
|
|
$wixObj = Join-Path $workDir "farmcontrol-server.wixobj"
|
|
|
|
if (Test-Path $workDir) {
|
|
Remove-Item $workDir -Recurse -Force
|
|
}
|
|
New-Item -ItemType Directory -Path $workDir | Out-Null
|
|
|
|
$candle = Find-WixTool "candle"
|
|
$light = Find-WixTool "light"
|
|
|
|
$wixVersion = ConvertTo-WixVersion $Version
|
|
$setupExePath = (Resolve-Path -LiteralPath $SetupExe).Path
|
|
$setupArchivePath = (Resolve-Path -LiteralPath $SetupArchive).Path
|
|
$setupMetadataPath = (Resolve-Path -LiteralPath $SetupMetadata).Path
|
|
|
|
$candleArgs = @(
|
|
'-nologo'
|
|
'-out'
|
|
$wixObj
|
|
"-dVersion=$wixVersion"
|
|
"-dSetupExe=$setupExePath"
|
|
"-dSetupArchive=$setupArchivePath"
|
|
"-dSetupMetadata=$setupMetadataPath"
|
|
$wxsPath
|
|
)
|
|
|
|
& $candle @candleArgs
|
|
|
|
$lightArgs = @(
|
|
'-nologo'
|
|
'-out'
|
|
$OutputMsi
|
|
$wixObj
|
|
)
|
|
|
|
& $light @lightArgs
|
|
|
|
if (-not (Test-Path $OutputMsi)) {
|
|
throw "MSI was not created at $OutputMsi"
|
|
}
|
|
|
|
Write-Host "Created MSI at $OutputMsi"
|