Skip to content

Commit 5a00387

Browse files
authored
feat: support vs2022 (#2533)
1 parent fb85fb2 commit 5a00387

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

.github/workflows/visual-studio.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Tests on Windows
2+
on: [push, pull_request]
3+
jobs:
4+
Tests:
5+
strategy:
6+
fail-fast: false
7+
max-parallel: 15
8+
matrix:
9+
os: [windows-2022]
10+
runs-on: ${{ matrix.os }}
11+
steps:
12+
- name: Checkout Repository
13+
uses: actions/checkout@v2
14+
- name: Install Dependencies
15+
run: |
16+
npm install --no-progress
17+
- name: Set Windows environment
18+
if: matrix.os == 'windows-latest'
19+
run: |
20+
echo 'GYP_MSVS_VERSION=2015' >> $Env:GITHUB_ENV
21+
echo 'GYP_MSVS_OVERRIDE_PATH=C:\\Dummy' >> $Env:GITHUB_ENV
22+
- name: Environment Information
23+
run: npx envinfo
24+
- name: Run Node tests
25+
run: npm test

lib/find-visualstudio.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
const log = require('npmlog')
44
const execFile = require('child_process').execFile
5+
const fs = require('fs')
56
const path = require('path').win32
67
const logWithPrefix = require('./util').logWithPrefix
78
const regSearchKeys = require('./util').regSearchKeys
@@ -257,22 +258,31 @@ VisualStudioFinder.prototype = {
257258
ret.versionYear = 2019
258259
return ret
259260
}
261+
if (ret.versionMajor === 17) {
262+
ret.versionYear = 2022
263+
return ret
264+
}
260265
this.log.silly('- unsupported version:', ret.versionMajor)
261266
return {}
262267
},
263268

264269
// Helper - process MSBuild information
265270
getMSBuild: function getMSBuild (info, versionYear) {
266271
const pkg = 'Microsoft.VisualStudio.VC.MSBuild.Base'
272+
const msbuildPath = path.join(info.path, 'MSBuild', 'Current', 'Bin', 'MSBuild.exe')
267273
if (info.packages.indexOf(pkg) !== -1) {
268274
this.log.silly('- found VC.MSBuild.Base')
269275
if (versionYear === 2017) {
270276
return path.join(info.path, 'MSBuild', '15.0', 'Bin', 'MSBuild.exe')
271277
}
272278
if (versionYear === 2019) {
273-
return path.join(info.path, 'MSBuild', 'Current', 'Bin', 'MSBuild.exe')
279+
return msbuildPath
274280
}
275281
}
282+
// visual studio 2022 don't has msbuild pkg
283+
if (fs.existsSync(msbuildPath)) {
284+
return msbuildPath
285+
}
276286
return null
277287
},
278288

@@ -293,6 +303,8 @@ VisualStudioFinder.prototype = {
293303
return 'v141'
294304
} else if (versionYear === 2019) {
295305
return 'v142'
306+
} else if (versionYear === 2022) {
307+
return 'v143'
296308
}
297309
this.log.silly('- invalid versionYear:', versionYear)
298310
return null

0 commit comments

Comments
 (0)