@@ -54,8 +54,10 @@ class VisualStudioFinder {
54
54
}
55
55
56
56
const checks = [
57
+ ( ) => this . findVisualStudio2019OrNewerFromSpecifiedLocation ( ) ,
57
58
( ) => this . findVisualStudio2019OrNewerUsingSetupModule ( ) ,
58
59
( ) => this . findVisualStudio2019OrNewer ( ) ,
60
+ ( ) => this . findVisualStudio2017FromSpecifiedLocation ( ) ,
59
61
( ) => this . findVisualStudio2017UsingSetupModule ( ) ,
60
62
( ) => this . findVisualStudio2017 ( ) ,
61
63
( ) => this . findVisualStudio2015 ( ) ,
@@ -116,6 +118,44 @@ class VisualStudioFinder {
116
118
throw new Error ( 'Could not find any Visual Studio installation to use' )
117
119
}
118
120
121
+ async findVisualStudio2019OrNewerFromSpecifiedLocation ( ) {
122
+ return this . findVSFromSpecifiedLocation ( [ 2019 , 2022 ] )
123
+ }
124
+
125
+ async findVisualStudio2017FromSpecifiedLocation ( ) {
126
+ if ( this . nodeSemver . major >= 22 ) {
127
+ this . addLog (
128
+ 'not looking for VS2017 as it is only supported up to Node.js 21' )
129
+ return null
130
+ }
131
+ return this . findVSFromSpecifiedLocation ( [ 2017 ] )
132
+ }
133
+
134
+ async findVSFromSpecifiedLocation ( supportedYears ) {
135
+ if ( ! this . envVcInstallDir ) {
136
+ return null
137
+ }
138
+ const info = {
139
+ path : path . resolve ( this . envVcInstallDir ) ,
140
+ // Assume the version specified by the user is correct.
141
+ version : process . env . VSCMD_VER ,
142
+ packages : [
143
+ 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64' ,
144
+ // Assume MSBuild exists. It will be checked in processing.
145
+ 'Microsoft.VisualStudio.VC.MSBuild.Base'
146
+ ]
147
+ }
148
+
149
+ // Is there a better way to get SDK information?
150
+ const envWindowsSDKVersion = process . env . WindowsSDKVersion
151
+ const sdkVersionMatched = envWindowsSDKVersion ?. match ( / ^ ( \d + ) \. ( \d + ) \. ( \d + ) \. .* / )
152
+ if ( sdkVersionMatched ) {
153
+ info . packages . push ( `Microsoft.VisualStudio.Component.Windows10SDK.${ sdkVersionMatched [ 3 ] } .Desktop` )
154
+ }
155
+ // pass for further processing
156
+ return this . processData ( [ info ] , supportedYears )
157
+ }
158
+
119
159
async findVisualStudio2019OrNewerUsingSetupModule ( ) {
120
160
return this . findNewVSUsingSetupModule ( [ 2019 , 2022 ] )
121
161
}
@@ -321,7 +361,7 @@ class VisualStudioFinder {
321
361
322
362
// Helper - process version information
323
363
getVersionInfo ( info ) {
324
- const match = / ^ ( \d + ) \. ( \d + ) \. .* / . exec ( info . version )
364
+ const match = / ^ ( \d + ) \. ( \d + ) (?: \. .* ) ? / . exec ( info . version )
325
365
if ( ! match ) {
326
366
this . log . silly ( '- failed to parse version:' , info . version )
327
367
return { }
0 commit comments