有没有办法执行 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/