Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

win: update supported vs versions #2959

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 () {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function should be removed. Also this should be a breaking change. commit. msg should be like

win!: update supported vs versions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed the commit message. Should I also add the semver-major label?

Regarding the removal of findVisualStudio2017, why do you think it should be removed? I've added it in this PR so that VS2017 can be prohibited on Node v22+, while VS2019 and VS2022 will be enabled. On previous Node versions all 3 VS versions should work, like they are working in the current main branch.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't follow the reasoning why this would be a breaking change. @gengjiawen Can you elaborate on this?

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