param( [string]$ProductVersion = '1.0.3', [string]$PublishDir = (Join-Path $PSScriptRoot '..\obj\setup-staging\app'), [string]$OutputDir = (Join-Path $PSScriptRoot '..\obj\setup-staging\installer') ) $ErrorActionPreference = 'Stop' $wix = Join-Path $PSScriptRoot '..\obj\installer-tools\wix.exe' if (-not (Test-Path -LiteralPath $wix)) { throw "WiX CLI not found: $wix" } $PublishDir = (Resolve-Path -LiteralPath $PublishDir).Path $migration = Join-Path $PSScriptRoot '..\add-resistance-column.sql' if (-not (Test-Path -LiteralPath $migration -PathType Leaf)) { throw "Missing resistance migration: $migration" } Copy-Item -LiteralPath $migration -Destination (Join-Path $PublishDir 'add-resistance-column.sql') -Force foreach ($file in @('Housing.exe', 'Housing.dll', 'Housing.runtimeconfig.json', 'hostfxr.dll', 'coreclr.dll', 'PresentationFramework.dll', 'Hardware.ini', 'Database.ini', 'InspectionSettings.ini', 'LoginOptions.json', 'add-resistance-column.sql')) { if (-not (Test-Path -LiteralPath (Join-Path $PublishDir $file) -PathType Leaf)) { throw "Missing publish file: $file" } } New-Item -ItemType Directory -Force -Path $OutputDir | Out-Null $output = Join-Path (Resolve-Path -LiteralPath $OutputDir).Path 'Housing.msi' & $wix build (Join-Path $PSScriptRoot 'Housing.wxs') -arch x64 -d "PublishDir=$PublishDir" -d "ProductVersion=$ProductVersion" -o $output if ($LASTEXITCODE -ne 0) { throw "WiX build failed (exit $LASTEXITCODE)." } Write-Host "Unsigned installer: $output" $bundle = Join-Path (Resolve-Path -LiteralPath $OutputDir).Path 'HousingSetup.exe' $bal = Join-Path $PSScriptRoot '..\.wix\extensions\WixToolset.Bal.wixext\6.0.2\wixext6\WixToolset.BootstrapperApplications.wixext.dll' if (-not (Test-Path -LiteralPath $bal)) { throw "WiX bootstrapper extension missing: $bal. MSI remains available at $output." } & $wix build (Join-Path $PSScriptRoot 'Bundle.wxs') -arch x64 -ext $bal -d "MsiFile=$output" -d "ProductVersion=$ProductVersion" -o $bundle if ($LASTEXITCODE -ne 0) { throw "WiX bundle build failed (exit $LASTEXITCODE). MSI remains available at $output." } Write-Host "Unsigned installer: $bundle"