如何從Visual Studio代碼運行Windows Bash作爲運行任務?Windows Bash和Visual Studio代碼:如何將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"
變量真假在一些案件,但無濟於事。
有誰知道如何做到這一點?
一個不太冒險的解決方案是嘗試運行'C:\ Windows \ sysnative \ bash.exe'。 –
你能編輯你的文章以包含你使用過的tasks.json或launch.json嗎? – atzero
我所謂的'解決方案',無論出於何種原因,都停止了工作......調查。 –