Skip to content

Commit 5f81b4e

Browse files
authored
[CI] Fix WIX integration. (#6)
1 parent 77b76a7 commit 5f81b4e

2 files changed

Lines changed: 30 additions & 6 deletions

File tree

‎.github/workflows/build-sounds.yml‎

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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

‎windows/build-msi.ps1‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#>
2727
param(
2828
[Parameter(Mandatory = $true)][string]$Tarball,
29-
[string]$WixTargetsPath,
29+
[string]$WixTargetsPath = $env:WixTargetsPath,
3030
[string]$Configuration = "Release",
3131
[string]$Platform = "x64"
3232
)
@@ -55,9 +55,16 @@ if (Test-Path $dest) { Remove-Item -Recurse -Force $dest }
5555

5656
# 3. Build the MSI. The project's EnsureSoundFiles target extracts $SoundTarball
5757
# (built-in tar) into libs/sounds/<suffix> before heat runs.
58-
if (-not $WixTargetsPath -and $env:WIX) {
58+
# Only override WixTargetsPath with a file that actually exists; otherwise leave
59+
# it empty so the wixproj's own fallback ($(MSBuildExtensionsPath32)\Microsoft\
60+
# WiX\v3.x\Wix.targets) resolves the standard install location.
61+
if (-not $WixTargetsPath -and $env:WIX -and (Test-Path (Join-Path $env:WIX "Wix.targets"))) {
5962
$WixTargetsPath = Join-Path $env:WIX "Wix.targets"
6063
}
64+
if ($WixTargetsPath -and -not (Test-Path $WixTargetsPath)) {
65+
Write-Host "WixTargetsPath '$WixTargetsPath' not found; deferring to the project's default."
66+
$WixTargetsPath = ""
67+
}
6168

6269
$sln = Join-Path $here "Setup.Sounds.2017.sln"
6370
$msbuildArgs = @(

0 commit comments

Comments
 (0)