2020 type : string
2121
2222env :
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
2525
2626jobs :
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
2929 runs-on : ${{ inputs.windows-runner || 'windows-latest' }}
3030 steps :
3131 - name : Checkout
32323333
3434 - name : Set up build
35+ id : setup-build
3536 uses : ./.github/actions/setup-build
3637 with :
3738 windows-sdk-version : ${{ env.TEST_WIN_SDK_VERSION }}
@@ -80,19 +81,11 @@ jobs:
8081 $InstallerLocation = Join-Path "${env:ProgramFiles(x86)}" "Microsoft Visual Studio" "Installer"
8182 $VSWhere = Join-Path "${InstallerLocation}" "vswhere.exe"
8283 $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) {
9386 Write-Output "✅ MSVC version `${env:TEST_MSVC_VERSION}`" is installed."
9487 } else {
95- Write-Output "::error::Expected MSVC version not found: `"${env:TEST_MSVC_VERSION }`"."
88+ Write-Output "::error::MSVC directory not found: `"${MSVCDir }`"."
9689 $HasError = $true
9790 }
9891
10396 $lastLine = $clOutput | Select-Object -Last 1
10497 Remove-Item $tempFile -Force
10598
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 .
107100 $ParsedMSVCVersion = [System.Version]::Parse($env:TEST_MSVC_VERSION)
108101 $ExpectedVersion = ($ParsedMSVCVersion.Major + 5) * 100 + $ParsedMSVCVersion.Minor
109102 if ($lastLine -eq $ExpectedVersion) {
@@ -113,7 +106,7 @@ jobs:
113106 $HasError = $true
114107 }
115108
116- # Check if the Windows SDK version is set in the environment.
109+ # Check that the Windows SDK version is set in the environment.
117110 if ($env:UCRTVersion -eq $env:TEST_WIN_SDK_VERSION) {
118111 Write-Output "✅ UCRTVersion environment variable is set to `"${env:TEST_WIN_SDK_VERSION}`"."
119112 } else {
@@ -127,3 +120,92 @@ jobs:
127120 } else {
128121 Write-Output "🎉 All environment checks passed successfully."
129122 }
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+ 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