如何从 Visual Studio 代码运行 Windows Bash 作为运行任务?
以下是我的许多尝试中的一些tasks.json
。
{
"version": "0.1.0",
"command": "cmd",
"isShellCommand": true,
"args": [ "RunShellScript.bat" ],
"showOutput": "always"
}
RunShellScript.bat 只有这一行:bash myShellScript.sh
. 如果您只是从开始打开 cmd 并键入该行,它将执行。如果您也只需双击该文件,它也可以完美运行。但是,当从 VSCode 启动时,这个输出会一直挂起,直到我终止它。
尝试2:
{
"version": "0.1.0",
"command": "cmd",
"isShellCommand": true,
"args": [ "bash myShellScript.sh" ],
"showOutput": "always"
}
这也挂起,就像上面一样。
尝试3:
{
"version": "0.1.0",
"command": "C:/Windows/System32/bash",
"isShellCommand": false,
"args": [ "myShellScript.sh" ],
"showOutput": "always"
}
这给了我:
Failed to launch external program C:/Windows/System32/bash myShellScript.sh
spawn C:/Windows/System32/bash ENOENT
在某些情况下,我还尝试将"isShellCommand"
变量设置为 true 和 false,但无济于事。
有谁知道如何做到这一点?