Skip to content

Commit

Permalink
feat: support vs2022 (#2533)
Browse files Browse the repository at this point in the history
  • Loading branch information
gengjiawen authored Oct 29, 2021
1 parent fb85fb2 commit 5a00387
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
25 changes: 25 additions & 0 deletions .github/workflows/visual-studio.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Tests on Windows
on: [push, pull_request]
jobs:
Tests:
strategy:
fail-fast: false
max-parallel: 15
matrix:
os: [windows-2022]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Install Dependencies
run: |
npm install --no-progress
- name: Set Windows environment
if: matrix.os == 'windows-latest'
run: |
echo 'GYP_MSVS_VERSION=2015' >> $Env:GITHUB_ENV
echo 'GYP_MSVS_OVERRIDE_PATH=C:\\Dummy' >> $Env:GITHUB_ENV
- name: Environment Information
run: npx envinfo
- name: Run Node tests
run: npm test
14 changes: 13 additions & 1 deletion lib/find-visualstudio.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const log = require('npmlog')
const execFile = require('child_process').execFile
const fs = require('fs')
const path = require('path').win32
const logWithPrefix = require('./util').logWithPrefix
const regSearchKeys = require('./util').regSearchKeys
Expand Down Expand Up @@ -257,22 +258,31 @@ VisualStudioFinder.prototype = {
ret.versionYear = 2019
return ret
}
if (ret.versionMajor === 17) {
ret.versionYear = 2022
return ret
}
this.log.silly('- unsupported version:', ret.versionMajor)
return {}
},

// Helper - process MSBuild information
getMSBuild: function getMSBuild (info, versionYear) {
const pkg = 'Microsoft.VisualStudio.VC.MSBuild.Base'
const msbuildPath = path.join(info.path, 'MSBuild', 'Current', 'Bin', 'MSBuild.exe')
if (info.packages.indexOf(pkg) !== -1) {
this.log.silly('- found VC.MSBuild.Base')
if (versionYear === 2017) {
return path.join(info.path, 'MSBuild', '15.0', 'Bin', 'MSBuild.exe')
}
if (versionYear === 2019) {
return path.join(info.path, 'MSBuild', 'Current', 'Bin', 'MSBuild.exe')
return msbuildPath
}
}
// visual studio 2022 don't has msbuild pkg
if (fs.existsSync(msbuildPath)) {
return msbuildPath
}
return null
},

Expand All @@ -293,6 +303,8 @@ VisualStudioFinder.prototype = {
return 'v141'
} else if (versionYear === 2019) {
return 'v142'
} else if (versionYear === 2022) {
return 'v143'
}
this.log.silly('- invalid versionYear:', versionYear)
return null
Expand Down

0 comments on commit 5a00387

Please sign in to comment.