Skip to content

Commit 6ca1f50

Browse files
committed
Fix Windows build: Update Visual Studio detection for new installation paths
Visual Studio on Windows Server 2022 is installed in 'C:\Program Files\Microsoft Visual Studio' instead of 'C:\Program Files (x86)\Microsoft Visual Studio'. Updated the PowerShell script to check both locations to ensure compatibility with all Windows runner versions.
1 parent f561959 commit 6ca1f50

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

.github/scripts/build-windows.ps1

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,10 @@ function Initialize-VS {
6767
# https://docs.microsoft.com/en-us/cpp/build/building-on-the-command-line
6868
# https://docs.microsoft.com/en-us/cpp/porting/binary-compat-2015-2017
6969

70-
$VS_ROOT = "C:\Program Files (x86)\Microsoft Visual Studio"
70+
$VS_ROOTS = @(
71+
"C:\Program Files\Microsoft Visual Studio",
72+
"C:\Program Files (x86)\Microsoft Visual Studio"
73+
)
7174
$VS_VERSIONS = @("2017", "2019", "2022")
7275
$VS_EDITIONS = @("Enterprise", "Professional", "Community")
7376
$VS_INIT_CMD_SUFFIX = "Common7\Tools\vsdevcmd.bat"
@@ -76,12 +79,14 @@ function Initialize-VS {
7679
$VS_INIT_ARGS = "-arch=$VS_ARCH -no_logo"
7780

7881
$found = $false
79-
:outer foreach ($version in $VS_VERSIONS) {
80-
foreach ($edition in $VS_EDITIONS) {
81-
$VS_INIT_CMD = "$VS_ROOT\$version\$edition\$VS_INIT_CMD_SUFFIX"
82-
if (Test-Path $VS_INIT_CMD) {
83-
$found = $true
84-
break outer
82+
:outer foreach ($VS_ROOT in $VS_ROOTS) {
83+
foreach ($version in $VS_VERSIONS) {
84+
foreach ($edition in $VS_EDITIONS) {
85+
$VS_INIT_CMD = "$VS_ROOT\$version\$edition\$VS_INIT_CMD_SUFFIX"
86+
if (Test-Path $VS_INIT_CMD) {
87+
$found = $true
88+
break outer
89+
}
8590
}
8691
}
8792
}

0 commit comments

Comments
 (0)