visual-studio-code - 如何使用 launch.json 在 Visual Studio Code 中运行命令

标签 visual-studio-code

有没有办法执行 ssh使用 .vscode/launch.json 调试项目时的命令?
例如:ssh -i xxxxx .
或者是否可以创建一个可以从 F1 命令面板弹出窗口运行的命令?类似 RunCustomCommandxx .

最佳答案

您可以定义一个 task在您的 tasks.json文件并将其指定为 preLaunchTask在您的 launch.json并且任务将在调试开始之前执行。

例子:

在tasks.json :

对于 0.1.0 版:

{
    "version": "0.1.0",
    "tasks": [{
        "taskName": "echotest",
        "command": "echo", // Could be any other shell command
        "args": ["test"],
        "isShellCommand": true
    }]
}

对于 2.0.0 版(更新和推荐):
{
    "version": "2.0.0",
    "tasks": [{
        "label": "echotest",
        "command": "echo", // Could be any other shell command
        "args": ["test"],
        "type": "shell"
    }]
}

在launch.json中:
{
    "configurations": [
        {
            // ...
            "preLaunchTask": "echotest", // The name of the task defined above
            // ...
        }
    ]   
}

任务文档:https://code.visualstudio.com/docs/editor/tasks

启动配置:https://code.visualstudio.com/docs/editor/debugging#_launch-configurations

关于visual-studio-code - 如何使用 launch.json 在 Visual Studio Code 中运行命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43836861/

相关文章:

javascript - VSCode ProblemMatcher 严重性映射

javascript - 如何使用命令删除未使用的导入?

c++ - 使用 Visual Studio 代码进行远程调试(C++)

f# - 如何运行 websharper 项目?

visual-studio-code - 阻止Visual Studio代码自动在.vue文件中添加分号

visual-studio-code - 无法启动客户端 Rust 语言服务器

visual-studio-code - 在不同端口上使用 VS Code 调试 2 个 nodemon 实例

flutter run 给出 Gradle 任务 assembleDebug 失败,退出代码 1

visual-studio-code - VSCode : normal word completion

terminal - Windows 10 更新后,visual studio code 终端以淡蓝色突出显示