Skip to content

Commit 4304903

Browse files
committed
CI: fix ATL install -- scope ARM64 component to ARM64 runner, verify install
The first ATL step requested VC.ATL.ARM64 on the x64 runner, which makes the whole VS Installer modify fail, so base VC.ATL was never installed and the build still failed on atlstr.h. Add the ARM64 component only on the ARM64 runner, check the installer exit code, and verify atlstr.h exists afterward.
1 parent 5c62eaf commit 4304903

2 files changed

Lines changed: 70 additions & 18 deletions

File tree

.github/workflows/build.yml

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,21 +88,47 @@ jobs:
8888
# The native C++ projects include ATL headers (<atlstr.h>, <atlcoll.h> in
8989
# FlyNativeLib). The windows-latest runner image no longer ships the C++ ATL
9090
# component by default, so install it into the runner's VS before building.
91-
# The .ARM64 component is added too so the ARM64 leg of a "Both" build works
92-
# on windows-11-arm; it is harmless on the x64 runner.
9391
- name: Install C++ ATL
9492
if: ${{ inputs.native == 'Build fresh' }}
9593
shell: pwsh
9694
run: |
9795
$vsInstaller = "C:\Program Files (x86)\Microsoft Visual Studio\Installer"
9896
$vsPath = & "$vsInstaller\vswhere.exe" -latest -property installationPath
99-
$args = @(
100-
"modify", "--installPath", "$vsPath",
101-
"--add", "Microsoft.VisualStudio.Component.VC.ATL",
102-
"--add", "Microsoft.VisualStudio.Component.VC.ATL.ARM64",
103-
"--quiet", "--norestart", "--nocache"
104-
)
105-
Start-Process -FilePath "$vsInstaller\setup.exe" -ArgumentList $args -Wait -PassThru
97+
if (-not $vsPath) { Write-Error "Could not locate Visual Studio via vswhere."; exit 1 }
98+
99+
# Base ATL provides the headers (atlstr.h etc.) FlyNativeLib needs. The
100+
# ARM64 variant (ATL link libs for ARM64 targets) is added ONLY on the
101+
# ARM64 runner -- requesting it on the x64 runner can make the whole
102+
# modify fail, leaving even base ATL uninstalled.
103+
$components = @("Microsoft.VisualStudio.Component.VC.ATL")
104+
if ("${{ matrix.platform }}" -eq "ARM64") {
105+
$components += "Microsoft.VisualStudio.Component.VC.ATL.ARM64"
106+
}
107+
108+
$vsArgs = @("modify", "--installPath", $vsPath, "--quiet", "--norestart", "--force", "--nocache")
109+
foreach ($c in $components) { $vsArgs += @("--add", $c) }
110+
111+
Write-Host "Installing ATL components: $($components -join ', ')"
112+
$proc = Start-Process -FilePath "$vsInstaller\setup.exe" -ArgumentList $vsArgs -Wait -PassThru -NoNewWindow
113+
Write-Host "VS Installer exit code: $($proc.ExitCode)"
114+
if ($proc.ExitCode -ne 0 -and $proc.ExitCode -ne 3010) {
115+
Write-Error "VS Installer modify failed with exit code $($proc.ExitCode)."
116+
exit $proc.ExitCode
117+
}
118+
119+
# Verify the header is actually present -- fail here with a clear message
120+
# rather than letting the later C++ compile fail on a missing include.
121+
# The VS Installer can land files slightly after setup.exe returns, so
122+
# poll for up to ~60s before giving up.
123+
$vcRoot = Join-Path $vsPath "VC\Tools\MSVC"
124+
$atl = $null
125+
foreach ($i in 1..12) {
126+
$atl = Get-ChildItem -Path $vcRoot -Recurse -Filter "atlstr.h" -ErrorAction SilentlyContinue | Select-Object -First 1
127+
if ($atl) { break }
128+
Start-Sleep -Seconds 5
129+
}
130+
if (-not $atl) { Write-Error "atlstr.h still not found under $vcRoot after install."; exit 1 }
131+
Write-Host "Found ATL header: $($atl.FullName)"
106132
107133
# Install the stable Rust toolchain and pre-add the cross-compilation
108134
# target for this platform. On windows-latest the host IS x86_64 so

.github/workflows/build_installer.yaml

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,21 +89,47 @@ jobs:
8989
# The native C++ projects include ATL headers (<atlstr.h>, <atlcoll.h> in
9090
# FlyNativeLib). The windows-latest runner image no longer ships the C++ ATL
9191
# component by default, so install it into the runner's VS before building.
92-
# The .ARM64 component is added too so the ARM64 leg of a "Both" build works
93-
# on windows-11-arm; it is harmless on the x64 runner.
9492
- name: Install C++ ATL
9593
if: ${{ inputs.native == 'Build fresh' }}
9694
shell: pwsh
9795
run: |
9896
$vsInstaller = "C:\Program Files (x86)\Microsoft Visual Studio\Installer"
9997
$vsPath = & "$vsInstaller\vswhere.exe" -latest -property installationPath
100-
$args = @(
101-
"modify", "--installPath", "$vsPath",
102-
"--add", "Microsoft.VisualStudio.Component.VC.ATL",
103-
"--add", "Microsoft.VisualStudio.Component.VC.ATL.ARM64",
104-
"--quiet", "--norestart", "--nocache"
105-
)
106-
Start-Process -FilePath "$vsInstaller\setup.exe" -ArgumentList $args -Wait -PassThru
98+
if (-not $vsPath) { Write-Error "Could not locate Visual Studio via vswhere."; exit 1 }
99+
100+
# Base ATL provides the headers (atlstr.h etc.) FlyNativeLib needs. The
101+
# ARM64 variant (ATL link libs for ARM64 targets) is added ONLY on the
102+
# ARM64 runner -- requesting it on the x64 runner can make the whole
103+
# modify fail, leaving even base ATL uninstalled.
104+
$components = @("Microsoft.VisualStudio.Component.VC.ATL")
105+
if ("${{ matrix.platform }}" -eq "ARM64") {
106+
$components += "Microsoft.VisualStudio.Component.VC.ATL.ARM64"
107+
}
108+
109+
$vsArgs = @("modify", "--installPath", $vsPath, "--quiet", "--norestart", "--force", "--nocache")
110+
foreach ($c in $components) { $vsArgs += @("--add", $c) }
111+
112+
Write-Host "Installing ATL components: $($components -join ', ')"
113+
$proc = Start-Process -FilePath "$vsInstaller\setup.exe" -ArgumentList $vsArgs -Wait -PassThru -NoNewWindow
114+
Write-Host "VS Installer exit code: $($proc.ExitCode)"
115+
if ($proc.ExitCode -ne 0 -and $proc.ExitCode -ne 3010) {
116+
Write-Error "VS Installer modify failed with exit code $($proc.ExitCode)."
117+
exit $proc.ExitCode
118+
}
119+
120+
# Verify the header is actually present -- fail here with a clear message
121+
# rather than letting the later C++ compile fail on a missing include.
122+
# The VS Installer can land files slightly after setup.exe returns, so
123+
# poll for up to ~60s before giving up.
124+
$vcRoot = Join-Path $vsPath "VC\Tools\MSVC"
125+
$atl = $null
126+
foreach ($i in 1..12) {
127+
$atl = Get-ChildItem -Path $vcRoot -Recurse -Filter "atlstr.h" -ErrorAction SilentlyContinue | Select-Object -First 1
128+
if ($atl) { break }
129+
Start-Sleep -Seconds 5
130+
}
131+
if (-not $atl) { Write-Error "atlstr.h still not found under $vcRoot after install."; exit 1 }
132+
Write-Host "Found ATL header: $($atl.FullName)"
107133
108134
# Install the stable Rust toolchain and pre-add the cross-compilation
109135
# target for this platform. On windows-latest the host IS x86_64 so

0 commit comments

Comments
 (0)