20
20
type : string
21
21
22
22
env :
23
- TEST_WIN_SDK_VERSION : 10.0.22621 .0
24
- TEST_MSVC_VERSION : 14.42
23
+ TEST_WIN_SDK_VERSION : 10.0.22000 .0
24
+ TEST_MSVC_VERSION : 14.40
25
25
26
26
jobs :
27
- test-setup-build-windows :
28
- name : Test MSVC and Windows SDK environment setup
27
+ test-setup-build-windows-vs-dev-env :
28
+ name : MSVC + WinSDK With Dev Environment
29
29
runs-on : ${{ inputs.windows-runner || 'windows-latest' }}
30
30
steps :
31
31
- name : Checkout
32
32
uses : actions/checkout@v4.2.2
33
33
34
34
- name : Set up build
35
+ id : setup-build
35
36
uses : ./.github/actions/setup-build
36
37
with :
37
38
windows-sdk-version : ${{ env.TEST_WIN_SDK_VERSION }}
@@ -80,19 +81,11 @@ jobs:
80
81
$InstallerLocation = Join-Path "${env:ProgramFiles(x86)}" "Microsoft Visual Studio" "Installer"
81
82
$VSWhere = Join-Path "${InstallerLocation}" "vswhere.exe"
82
83
$InstallPath = (& "$VSWhere" -latest -products * -format json | ConvertFrom-Json).installationPath
83
- $MSVCDir = Join-Path $InstallPath "VC" "Tools" "MSVC"
84
- $DirFound = $false
85
- foreach ($dir in Get-ChildItem -Path $MSVCDir -Directory) {
86
- $MSVCDirName = $dir.Name
87
- if ($MSVCDirName.StartsWith($env:TEST_MSVC_VERSION)) {
88
- $DirFound = $true
89
- break
90
- }
91
- }
92
- if ($DirFound) {
84
+ $MSVCDir = Join-Path $InstallPath "VC" "Tools" "MSVC" "${{ steps.setup-build.outputs.windows-build-tools-version }}"
85
+ if (Test-Path -Path $MSVCDir) {
93
86
Write-Output "✅ MSVC version `${env:TEST_MSVC_VERSION}`" is installed."
94
87
} else {
95
- Write-Output "::error::Expected MSVC version not found: `"${env:TEST_MSVC_VERSION }`"."
88
+ Write-Output "::error::MSVC directory not found: `"${MSVCDir }`"."
96
89
$HasError = $true
97
90
}
98
91
103
96
$lastLine = $clOutput | Select-Object -Last 1
104
97
Remove-Item $tempFile -Force
105
98
106
- # _MSC_VER expands to a number like 1942 for MSVC 14.42 .
99
+ # _MSC_VER expands to a number like 1940 for MSVC 14.40 .
107
100
$ParsedMSVCVersion = [System.Version]::Parse($env:TEST_MSVC_VERSION)
108
101
$ExpectedVersion = ($ParsedMSVCVersion.Major + 5) * 100 + $ParsedMSVCVersion.Minor
109
102
if ($lastLine -eq $ExpectedVersion) {
@@ -113,7 +106,7 @@ jobs:
113
106
$HasError = $true
114
107
}
115
108
116
- # Check if the Windows SDK version is set in the environment.
109
+ # Check that the Windows SDK version is set in the environment.
117
110
if ($env:UCRTVersion -eq $env:TEST_WIN_SDK_VERSION) {
118
111
Write-Output "✅ UCRTVersion environment variable is set to `"${env:TEST_WIN_SDK_VERSION}`"."
119
112
} else {
@@ -127,3 +120,92 @@ jobs:
127
120
} else {
128
121
Write-Output "🎉 All environment checks passed successfully."
129
122
}
123
+
124
+ test-setup-build-windows-no-dev-env :
125
+ name : MSVC + WinSDK No Dev Environment
126
+ runs-on : ${{ inputs.windows-runner || 'windows-latest' }}
127
+ steps :
128
+ - name : Checkout
129
+ uses : actions/checkout@v4.2.2
130
+
131
+ - name : Set up build
132
+ id : setup-build
133
+ uses : ./.github/actions/setup-build
134
+ with :
135
+ windows-sdk-version : ${{ env.TEST_WIN_SDK_VERSION }}
136
+ msvc-version : ${{ env.TEST_MSVC_VERSION }}
137
+ setup-vs-dev-env : false
138
+
139
+ - name : Check environment
140
+ run : |
141
+ $HasError = $false
142
+
143
+ $ParsedWinSdkVersion = [System.Version]::Parse($env:TEST_WIN_SDK_VERSION)
144
+ $Win10SdkRoot = Get-ItemPropertyValue `
145
+ -Path "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed Roots" `
146
+ -Name "KitsRoot10"
147
+ $Win10SdkInclude = Join-Path $Win10SdkRoot "Include"
148
+
149
+ # Check if the Windows SDK version is installed.
150
+ $ExpectedWinSdkDir = Join-Path $Win10SdkInclude "$($env:TEST_WIN_SDK_VERSION)"
151
+ if (Test-Path -Path $ExpectedWinSdkDir) {
152
+ Write-Output "✅ Windows SDK version `"${env:TEST_WIN_SDK_VERSION}`" is installed."
153
+ } else {
154
+ Write-Output "::error::Expected Windows SDK version not found: `"${env:TEST_WIN_SDK_VERSION}`"."
155
+ $HasError = $true
156
+ }
157
+
158
+ # Check if Windows SDK versions greater than the expected version are installed.
159
+ $UnexpectedSdkFound = $false
160
+ Get-ChildItem -Path $Win10SdkInclude -Directory | ForEach-Object {
161
+ $Version = $_.Name
162
+ try {
163
+ $ParsedVersion = [System.Version]::Parse($Version)
164
+ if ($ParsedVersion -gt $ParsedWinSdkVersion) {
165
+ Write-Output "::error::Unexpected Windows SDK version found: `"${Version}`" (greater than expected: `"${env:TEST_WIN_SDK_VERSION}`")."
166
+ $HasError = $true
167
+ $UnexpectedSdkFound = $true
168
+ }
169
+ } catch {
170
+ # Skip if the directory cannot be parsed as a version.
171
+ }
172
+ }
173
+ if (-not $UnexpectedSdkFound) {
174
+ Write-Output "✅ No unexpected Windows SDK versions greater than `"${env:TEST_WIN_SDK_VERSION}`" found."
175
+ }
176
+
177
+ # Check if the correct MSVC version is installed.
178
+ $InstallerLocation = Join-Path "${env:ProgramFiles(x86)}" "Microsoft Visual Studio" "Installer"
179
+ $VSWhere = Join-Path "${InstallerLocation}" "vswhere.exe"
180
+ $InstallPath = (& "$VSWhere" -latest -products * -format json | ConvertFrom-Json).installationPath
181
+ $MSVCDir = Join-Path $InstallPath "VC" "Tools" "MSVC" "${{ steps.setup-build.outputs.windows-build-tools-version }}"
182
+ if (Test-Path -Path $MSVCDir) {
183
+ Write-Output "✅ MSVC version `${env:TEST_MSVC_VERSION}`" is installed."
184
+ } else {
185
+ Write-Output "::error::MSVC directory not found: `"${MSVCDir}`"."
186
+ $HasError = $true
187
+ }
188
+
189
+ # Check that cl.exe was not set.
190
+ $CLExe = Get-Command -Name cl.exe -ErrorAction Ignore
191
+ if ($CLExe) {
192
+ Write-Output "::error::cl.exe was unexpectedly found in the PATH: `"${CLExe.Path}`"."
193
+ $HasError = $true
194
+ } else {
195
+ Write-Output "✅ cl.exe is not set in the PATH, as expected."
196
+ }
197
+
198
+ # Check that the VS Dev Environment was not set.
199
+ if ($env:UCRTVersion) {
200
+ Write-Output "::error::UCRTVersion environment variable was set to `"${env:UCRTVersion}`"."
201
+ $HasError = $true
202
+ } else {
203
+ Write-Output "✅ UCRTVersion environment variable is set to `"${env:TEST_WIN_SDK_VERSION}`"."
204
+ }
205
+
206
+ if ($HasError) {
207
+ Write-Output "::error::There were errors in the environment setup. Check the logs for details."
208
+ exit 1
209
+ } else {
210
+ Write-Output "🎉 All environment checks passed successfully."
211
+ }
0 commit comments