@@ -136,14 +136,31 @@ jobs:
136136 shell : pwsh
137137 run : |
138138 choco install wixtoolset -y --no-progress
139- # Discover the install dir (version may vary) and expose it via WIX so
140- # build-msi.ps1 / the wixproj resolve Wix.targets and the WiX tools.
141- $root = Get-ChildItem "C:\Program Files (x86)" -Directory -Filter "WiX Toolset v3*" |
139+
140+ $pf86 = ${env:ProgramFiles(x86)}
141+
142+ # Toolset install dir (bin\heat.exe, candle.exe, light.exe). Export as WIX.
143+ $root = Get-ChildItem $pf86 -Directory -Filter "WiX Toolset v3*" |
142144 Sort-Object Name -Descending | Select-Object -First 1
143145 if (-not $root) { throw "WiX Toolset v3 not found after install" }
144- "WIX=$($root.FullName)\" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
146+ "WIX=$($root.FullName)\" | Out-File $env:GITHUB_ENV -Append -Encoding utf8
145147 Write-Host "WIX=$($root.FullName)\"
146148
149+ # The WiX v3 MSBuild integration (wix.targets) location varies by
150+ # installer; the standard spot is MSBuild\Microsoft\WiX\v3.x. Find it.
151+ $candidates = @(
152+ (Join-Path $pf86 "MSBuild\Microsoft\WiX\v3.x\wix.targets"),
153+ (Join-Path $root.FullName "Wix.targets")
154+ )
155+ $targets = $candidates | Where-Object { Test-Path $_ } | Select-Object -First 1
156+ if (-not $targets) {
157+ $targets = Get-ChildItem (Join-Path $pf86 "MSBuild"), $root.FullName -Recurse -Filter "wix.targets" -ErrorAction SilentlyContinue |
158+ Select-Object -First 1 -ExpandProperty FullName
159+ }
160+ if (-not $targets) { throw "Could not locate WiX v3 wix.targets after install" }
161+ Write-Host "WixTargetsPath=$targets"
162+ "WixTargetsPath=$targets" | Out-File $env:GITHUB_ENV -Append -Encoding utf8
163+
147164 - name : Add MSBuild to PATH
148165 uses : microsoft/setup-msbuild@v3
149166
0 commit comments