@@ -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
0 commit comments