mirror of
https://github.com/ilammy/msvc-dev-cmd.git
synced 2026-09-06 21:57:19 +08:00
Detect and report vcvarsall.bat errors (#28)
If the parameters passed to the script are incorrect -- for example,
architecture is set to something the script does not understand --
then the script will print an error message *and* exit successfully
without doing anything useful.
Detect the error messages, forward them to the user, and fail the
action. Hopefully, the information from the script will be enough
to pinpoint the source of the issue.
For example, if the action is run
with:
arch: Win32
then the output will be
Found with vswhere: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat
Error: [ERROR:vcvarsall.bat] Invalid argument found : Win32
Error: Could not setup Developer Command Prompt: invalid parameters
which is close enough.
This commit is contained in:
@@ -104,6 +104,24 @@ function main() {
|
|||||||
core.debug(`Running: ${command}`)
|
core.debug(`Running: ${command}`)
|
||||||
const environment = child_process.execSync(command, {shell: "cmd"}).toString().split('\r\n')
|
const environment = child_process.execSync(command, {shell: "cmd"}).toString().split('\r\n')
|
||||||
|
|
||||||
|
// If vsvars.bat is given an incorrect command line, it will print out
|
||||||
|
// an error and *still* exit successfully. Parse out errors from output
|
||||||
|
// which don't look like environment variables, and fail if appropriate.
|
||||||
|
var failed = false
|
||||||
|
for (let line of environment) {
|
||||||
|
if (line.match(/^\[ERROR.*\]/)) {
|
||||||
|
failed = true
|
||||||
|
// Don't print this particular line which will be confusing in output.
|
||||||
|
if (line.match(/Error in script usage. The correct usage is:$/)) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
core.error(line)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (failed) {
|
||||||
|
throw new Error('invalid parameters')
|
||||||
|
}
|
||||||
|
|
||||||
for (let string of environment) {
|
for (let string of environment) {
|
||||||
const [name, value] = string.split('=')
|
const [name, value] = string.split('=')
|
||||||
for (let pattern of InterestingVariables) {
|
for (let pattern of InterestingVariables) {
|
||||||
|
|||||||
Reference in New Issue
Block a user