@@ -5,9 +5,11 @@ const path = require('path')
55const process = require ( 'process' )
66
77const PROGRAM_FILES_X86 = process . env [ 'ProgramFiles(x86)' ]
8+ const PROGRAM_FILES = [ process . env [ 'ProgramFiles(x86)' ] , process . env [ 'ProgramFiles' ] ]
9+
810
911const EDITIONS = [ 'Enterprise' , 'Professional' , 'Community' ]
10- const VERSIONS = [ '2019' , '2017' ]
12+ const VERSIONS = [ '2022' , ' 2019', '2017' ]
1113
1214const VSWHERE_PATH = `${ PROGRAM_FILES_X86 } \\Microsoft Visual Studio\\Installer`
1315
@@ -32,13 +34,15 @@ function findVcvarsall() {
3234
3335 // If that does not work, try the standard installation locations,
3436 // starting with the latest and moving to the oldest.
35- for ( const ver of VERSIONS ) {
36- for ( const ed of EDITIONS ) {
37- path = `${ PROGRAM_FILES_X86 } \\Microsoft Visual Studio\\${ ver } \\${ ed } \\VC\\Auxiliary\\Build\\vcvarsall.bat`
38- core . info ( `Trying standard location: ${ path } ` )
39- if ( fs . existsSync ( path ) ) {
40- core . info ( `Found standard location: ${ path } ` )
41- return path
37+ for ( const prog_files of PROGRAM_FILES ) {
38+ for ( const ver of VERSIONS ) {
39+ for ( const ed of EDITIONS ) {
40+ path = `${ prog_files } \\Microsoft Visual Studio\\${ ver } \\${ ed } \\VC\\Auxiliary\\Build\\vcvarsall.bat`
41+ core . info ( `Trying standard location: ${ path } ` )
42+ if ( fs . existsSync ( path ) ) {
43+ core . info ( `Found standard location: ${ path } ` )
44+ return path
45+ }
4246 }
4347 }
4448 }
@@ -70,7 +74,8 @@ function filterPathValue(path) {
7074 return paths . filter ( unique ) . join ( ';' )
7175}
7276
73- function main ( ) {
77+ /** See https://github.com/ilammy/msvc-dev-cmd#inputs */
78+ function setupMSVCDevCmd ( arch , sdk , toolset , uwp , spectre ) {
7479 if ( process . platform != 'win32' ) {
7580 core . info ( 'This is not a Windows virtual environment, bye!' )
7681 return
@@ -79,12 +84,6 @@ function main() {
7984 // Add standard location of "vswhere" to PATH, in case it's not there.
8085 process . env . PATH += path . delimiter + VSWHERE_PATH
8186
82- var arch = core . getInput ( 'arch' )
83- const sdk = core . getInput ( 'sdk' )
84- const toolset = core . getInput ( 'toolset' )
85- const uwp = core . getInput ( 'uwp' )
86- const spectre = core . getInput ( 'spectre' )
87-
8887 // There are all sorts of way the architectures are called. In addition to
8988 // values supported by Microsoft Visual C++, recognize some common aliases.
9089 let arch_aliases = {
@@ -177,6 +176,17 @@ function main() {
177176
178177 core . info ( `Configured Developer Command Prompt` )
179178}
179+ exports . setupMSVCDevCmd = setupMSVCDevCmd
180+
181+ function main ( ) {
182+ var arch = core . getInput ( 'arch' )
183+ const sdk = core . getInput ( 'sdk' )
184+ const toolset = core . getInput ( 'toolset' )
185+ const uwp = core . getInput ( 'uwp' )
186+ const spectre = core . getInput ( 'spectre' )
187+
188+ setupMSVCDevCmd ( arch , sdk , toolset , uwp , spectre )
189+ }
180190
181191try {
182192 main ( )
0 commit comments