Skip to content

Commit

Permalink
win: update supported vs versions (#2959)
Browse files Browse the repository at this point in the history
Drop VS2017 support for Node.js v22 and above.

Refs: nodejs/build#3603
Refs: nodejs/node#45427
  • Loading branch information
StefanStojanovic authored Mar 6, 2024
1 parent 109e3d4 commit 391cc5b
Show file tree
Hide file tree
Showing 2 changed files with 142 additions and 81 deletions.
50 changes: 41 additions & 9 deletions lib/find-visualstudio.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ class VisualStudioFinder {
}

const checks = [
() => this.findVisualStudio2017OrNewerUsingSetupModule(),
() => this.findVisualStudio2017OrNewer(),
() => this.findVisualStudio2019OrNewerUsingSetupModule(),
() => this.findVisualStudio2019OrNewer(),
() => this.findVisualStudio2017UsingSetupModule(),
() => this.findVisualStudio2017(),
() => this.findVisualStudio2015(),
() => this.findVisualStudio2013()
]
Expand Down Expand Up @@ -114,7 +116,20 @@ class VisualStudioFinder {
throw new Error('Could not find any Visual Studio installation to use')
}

async findVisualStudio2017OrNewerUsingSetupModule () {
async findVisualStudio2019OrNewerUsingSetupModule () {
return this.findNewVSUsingSetupModule([2019, 2022])
}

async findVisualStudio2017UsingSetupModule () {
if (this.nodeSemver.major >= 22) {
this.addLog(
'not looking for VS2017 as it is only supported up to Node.js 21')
return null
}
return this.findNewVSUsingSetupModule([2017])
}

async findNewVSUsingSetupModule (supportedYears) {
const ps = path.join(process.env.SystemRoot, 'System32',
'WindowsPowerShell', 'v1.0', 'powershell.exe')
const vcInstallDir = this.envVcInstallDir
Expand Down Expand Up @@ -157,12 +172,28 @@ class VisualStudioFinder {
return info
})
// pass for further processing
return this.processData(parsedData)
return this.processData(parsedData, supportedYears)
}

// Invoke the PowerShell script to get information about Visual Studio 2019
// or newer installations
async findVisualStudio2019OrNewer () {
return this.findNewVS([2019, 2022])
}

// Invoke the PowerShell script to get information about Visual Studio 2017
async findVisualStudio2017 () {
if (this.nodeSemver.major >= 22) {
this.addLog(
'not looking for VS2017 as it is only supported up to Node.js 21')
return null
}
return this.findNewVS([2017])
}

// Invoke the PowerShell script to get information about Visual Studio 2017
// or newer installations
async findVisualStudio2017OrNewer () {
async findNewVS (supportedYears) {
const ps = path.join(process.env.SystemRoot, 'System32',
'WindowsPowerShell', 'v1.0', 'powershell.exe')
const csFile = path.join(__dirname, 'Find-VisualStudio.cs')
Expand All @@ -180,7 +211,7 @@ class VisualStudioFinder {
if (parsedData === null) {
return null
}
return this.processData(parsedData)
return this.processData(parsedData, supportedYears)
}

// Parse the output of the PowerShell script, make sanity checks
Expand Down Expand Up @@ -224,7 +255,7 @@ class VisualStudioFinder {

// Process parsed data containing information about VS installations
// Look for the required parts, extract and output them back
processData (vsInfo) {
processData (vsInfo, supportedYears) {
vsInfo = vsInfo.map((info) => {
this.log.silly(`processing installation: "${info.path}"`)
info.path = path.resolve(info.path)
Expand All @@ -238,11 +269,12 @@ class VisualStudioFinder {
this.log.silly('vsInfo:', vsInfo)

// Remove future versions or errors parsing version number
// Also remove any unsupported versions
vsInfo = vsInfo.filter((info) => {
if (info.versionYear) {
if (info.versionYear && supportedYears.indexOf(info.versionYear) !== -1) {
return true
}
this.addLog(`unknown version "${info.version}" found at "${info.path}"`)
this.addLog(`${info.versionYear ? 'unsupported' : 'unknown'} version "${info.version}" found at "${info.path}"`)
return false
})

Expand Down
Loading

0 comments on commit 391cc5b

Please sign in to comment.