首页 > 解决方案 > VSCode构建任务打开shell并停止而不运行命令

问题描述

我目前正在尝试运行一个 build.bat 脚本,该脚本使用 VSCode 构建任务构建我的解决方案。不幸的是,它所做的只是打开命令提示符,而不按照说明运行实际命令。我目前正在尝试运行的任务是

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build",
            "type": "shell",
            "windows": {
                "options": {
                    "cwd": "W:\\handmade\\code",
                    "shell": {
                        "args": [
                            "/k W:\\handmade\\misc\\shell.bat"
                        ]
                    }
                },
                "command": "build.bat",
            },
            "problemMatcher": [
                "$gcc"
            ]
        }
    ]
}

我期望的输出是:

**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.8.4
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'

W:\handmade\code>build.bat
A subdirectory or file ..\..\build already exists.
Microsoft (R) C/C++ Optimizing Compiler Version 19.15.26729 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

win32_handmade.cpp
Microsoft (R) Incremental Linker Version 14.15.26729.0
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:win32_handmade.exe
/debug
win32_handmade.obj
user32.lib

如果我正常运行命令,我会得到什么,而我得到的是

> Executing task: build.bat <

**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.8.4
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'

W:\handmade\code>

然后它挂起,直到调用退出。tasks.json 中提供的命令显然从未尝试执行过,我不知道为什么会这样。

标签: batch-filecmdvisual-studio-codevscode-settingsvscode-tasks

解决方案


推荐阅读