@@ -227,12 +227,36 @@ runs:
227
227
Get-ChildItem Env: | % { echo "$($_.Name)=$($_.Value)" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append }
228
228
shell : pwsh
229
229
230
- - name : VS2022 Compatibility Setup
230
+ - name : Check Swift version
231
231
if : runner.os == 'Windows'
232
+ id : swift-version
233
+ shell : pwsh
234
+ run : |
235
+ $SwiftVersionOutput=$(swift --version)
236
+ if ("$SwiftVersionOutput" -match "[\d]+(\.[\d]+){0,2}") {
237
+ $SwiftSemVer=$Matches[0]
238
+
239
+ # Ensure we have at least MAJOR.MINOR or [System.Version] won't parse.
240
+ if (-Not ($SwiftSemVer -like "*.*")) {
241
+ $SwiftSemVer += ".0"
242
+ }
243
+
244
+ $SwiftVersion=[System.Version]($SwiftSemVer)
245
+
246
+ # If the toolchain is newer than 5.9 we don't need to ensure compatibility with VS2022.
247
+ if ($SwiftVersion -gt [System.Version]"5.9") {
248
+ "is_newer_than_5_9='true'" | Out-File $env:GITHUB_OUTPUT -Append -Encoding utf8
249
+ } else {
250
+ "is_newer_than_5_9='false'" | Out-File $env:GITHUB_OUTPUT -Append -Encoding utf8
251
+ }
252
+ }
253
+
254
+ - name : VS2022 Compatibility Setup
255
+ if : runner.os == 'Windows' && steps.swift-version.outputs.is_newer_than_5_9 == 'false'
232
256
uses : compnerd/gha-setup-vsdevenv@f1ba60d553a3216ce1b89abe0201213536bc7557 # v6
233
257
234
258
- name : VS2022 Compatibility Installation
235
- if : runner.os == 'Windows'
259
+ if : runner.os == 'Windows' && steps.swift-version.outputs.is_newer_than_5_9 == 'false'
236
260
run : |
237
261
Copy-Item "$env:SDKROOT\usr\share\ucrt.modulemap" -destination "$env:UniversalCRTSdkDir\Include\$env:UCRTVersion\ucrt\module.modulemap"
238
262
if (Test-Path -Path "$env:SDKROOT\usr\share\vcruntime.modulemap") {
0 commit comments