@@ -116,25 +116,27 @@ function main() {
116
116
const vcvars = `"${ findVcvarsall ( ) } " ${ args . join ( ' ' ) } `
117
117
core . debug ( `vcvars command-line: ${ vcvars } ` )
118
118
119
- const old_environment = child_process . execSync ( `set` , { shell : "cmd" } ) . toString ( ) . split ( '\r\n' )
120
- const new_environment = child_process . execSync ( `${ vcvars } && set` , { shell : "cmd" } ) . toString ( ) . split ( '\r\n' )
119
+ const cmd_output_string = child_process . execSync ( `set && cls && ${ vcvars } && cls && set` , { shell : "cmd" } ) . toString ( )
120
+ const cmd_output_parts = cmd_output_string . split ( '\f' )
121
+
122
+ const old_environment = cmd_output_parts [ 0 ] . split ( '\r\n' )
123
+ const vcvars_output = cmd_output_parts [ 1 ] . split ( '\r\n' )
124
+ const new_environment = cmd_output_parts [ 2 ] . split ( '\r\n' )
121
125
122
126
// If vsvars.bat is given an incorrect command line, it will print out
123
127
// an error and *still* exit successfully. Parse out errors from output
124
128
// which don't look like environment variables, and fail if appropriate.
125
- var failed = false
126
- for ( let line of new_environment ) {
129
+ const error_messages = vcvars_output . filter ( ( line ) => {
127
130
if ( line . match ( / ^ \[ E R R O R .* \] / ) ) {
128
- failed = true
129
131
// Don't print this particular line which will be confusing in output.
130
- if ( line . match ( / E r r o r i n s c r i p t u s a g e . T h e c o r r e c t u s a g e i s : $ / ) ) {
131
- continue
132
+ if ( ! line . match ( / E r r o r i n s c r i p t u s a g e . T h e c o r r e c t u s a g e i s : $ / ) ) {
133
+ return true
132
134
}
133
- core . error ( line )
134
135
}
135
- }
136
- if ( failed ) {
137
- throw new Error ( 'invalid parameters' )
136
+ return false
137
+ } )
138
+ if ( error_messages . length > 0 ) {
139
+ throw new Error ( 'invalid parameters' + '\r\n' + error_messages . join ( '\r\n' ) )
138
140
}
139
141
140
142
// Convert old environment lines into a dictionary for easier lookup.
0 commit comments