Skip to content

Commit ea8520e

Browse files
authored
feat: Update function getSDK() to support Windows 11 SDK (#2565)
1 parent 9778dd0 commit ea8520e

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

lib/find-visualstudio.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -314,29 +314,30 @@ VisualStudioFinder.prototype = {
314314
getSDK: function getSDK (info) {
315315
const win8SDK = 'Microsoft.VisualStudio.Component.Windows81SDK'
316316
const win10SDKPrefix = 'Microsoft.VisualStudio.Component.Windows10SDK.'
317+
const win11SDKPrefix = 'Microsoft.VisualStudio.Component.Windows11SDK.'
317318

318-
var Win10SDKVer = 0
319+
var Win10or11SDKVer = 0
319320
info.packages.forEach((pkg) => {
320-
if (!pkg.startsWith(win10SDKPrefix)) {
321+
if (!pkg.startsWith(win10SDKPrefix) && !pkg.startsWith(win11SDKPrefix)) {
321322
return
322323
}
323324
const parts = pkg.split('.')
324325
if (parts.length > 5 && parts[5] !== 'Desktop') {
325-
this.log.silly('- ignoring non-Desktop Win10SDK:', pkg)
326+
this.log.silly('- ignoring non-Desktop Win10/11SDK:', pkg)
326327
return
327328
}
328329
const foundSdkVer = parseInt(parts[4], 10)
329330
if (isNaN(foundSdkVer)) {
330331
// Microsoft.VisualStudio.Component.Windows10SDK.IpOverUsb
331-
this.log.silly('- failed to parse Win10SDK number:', pkg)
332+
this.log.silly('- failed to parse Win10/11SDK number:', pkg)
332333
return
333334
}
334-
this.log.silly('- found Win10SDK:', foundSdkVer)
335-
Win10SDKVer = Math.max(Win10SDKVer, foundSdkVer)
335+
this.log.silly('- found Win10/11SDK:', foundSdkVer)
336+
Win10or11SDKVer = Math.max(Win10or11SDKVer, foundSdkVer)
336337
})
337338

338-
if (Win10SDKVer !== 0) {
339-
return `10.0.${Win10SDKVer}.0`
339+
if (Win10or11SDKVer !== 0) {
340+
return `10.0.${Win10or11SDKVer}.0`
340341
} else if (info.packages.indexOf(win8SDK) !== -1) {
341342
this.log.silly('- found Win8SDK')
342343
return '8.1'

0 commit comments

Comments
 (0)