Skip to content

Commit 73ed7cd

Browse files
committed
One weird trick to get VS env variables
1 parent c6a5a23 commit 73ed7cd

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@ jobs:
1515

1616
- name: Check Formatting
1717
run: |
18-
$VSDevCmd = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere" -latest -find Common7\tools\VSDevCmd.bat
19-
if (!$VSDevCmd) { exit 1 }
20-
Write-Host "Using VSDevCmd: ${VSDevCmd}"
21-
& $VSDevCmd;
18+
$vcvars64 = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere" -latest -find VC\Auxiliary\Build\vcvars64.bat
19+
if (!$vcvars64) { exit 1 }
20+
Write-Host "Using vcvars64: ${vcvars64}"
21+
22+
# We need environment variables from running a batch file, but are running pwsh, so they would all be lost when cmd exits. We
23+
# circumvent this problem by launching a fresh pwsh process after the batch file runs so execution continues with them set.
24+
cmd "/k" '"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" & pwsh'
2225
2326
& .\find_clang_format.cmd
2427
if ($LASTEXITCODE -ne 0) {

0 commit comments

Comments
 (0)