param( [string]$PublishRoot = ".\artifacts\publish\net472", [string]$OutputRoot = ".\artifacts\msi" ) Set-StrictMode -Version Latest $ErrorActionPreference = 'Stop' function Get-WixTool { param([string]$Name) $cmd = Get-Command $Name -ErrorAction SilentlyContinue if ($cmd) { return $cmd.Source } throw "$Name was not found. Install WiX Toolset v3 and ensure heat.exe, candle.exe and light.exe are in PATH." } $repoRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) $publishRootFull = [System.IO.Path]::GetFullPath((Join-Path $repoRoot $PublishRoot)) $outputRootFull = [System.IO.Path]::GetFullPath((Join-Path $repoRoot $OutputRoot)) New-Item -Path $outputRootFull -ItemType Directory -Force | Out-Null $heat = Get-WixTool -Name 'heat.exe' $candle = Get-WixTool -Name 'candle.exe' $light = Get-WixTool -Name 'light.exe' $packages = @( @{ Name = 'HostAvailabilityMonitor'; ProductFile = 'HostAvailabilityMonitor.wxs'; HarvestFile = 'Harvest_HostAvailabilityMonitor.wxs'; PublishDir = 'HostAvailabilityMonitor'; ComponentGroup = 'MonitorHarvest' }, @{ Name = 'BizTalkMonitorConfigGenerator'; ProductFile = 'BizTalkMonitorConfigGenerator.wxs'; HarvestFile = 'Harvest_BizTalkMonitorConfigGenerator.wxs'; PublishDir = 'BizTalkMonitorConfigGenerator'; ComponentGroup = 'GeneratorHarvest' } ) foreach ($package in $packages) { $sourceDir = Join-Path $publishRootFull $package.PublishDir if (-not (Test-Path -LiteralPath $sourceDir)) { throw "Publish directory not found: $sourceDir" } $harvestPath = Join-Path $outputRootFull $package.HarvestFile $productPath = Join-Path $PSScriptRoot $package.ProductFile $productObj = Join-Path $outputRootFull ($package.Name + '.wixobj') $harvestObj = Join-Path $outputRootFull ($package.Name + '.harvest.wixobj') $msiPath = Join-Path $outputRootFull ($package.Name + '.msi') & $heat dir $sourceDir -cg $package.ComponentGroup -dr INSTALLDIR -gg -scom -sreg -sfrag -var var.SourceDir -out $harvestPath & $candle -ext WixNetFxExtension -dSourceDir=$sourceDir -out $productObj $productPath & $candle -ext WixNetFxExtension -dSourceDir=$sourceDir -out $harvestObj $harvestPath & $light -ext WixNetFxExtension -out $msiPath $productObj $harvestObj Write-Host "Built MSI: $msiPath" }