atz*_*ero 8 windows bash visual-studio-code windows-subsystem-for-linux
如何从Visual Studio代码运行Windows Bash作为运行任务?
以下是我尝试tasks.json这样做的一些尝试.
{
"version": "0.1.0",
"command": "cmd",
"isShellCommand": true,
"args": [ "RunShellScript.bat" ],
"showOutput": "always"
}
Run Code Online (Sandbox Code Playgroud)
RunShellScript.bat只有这一行:bash myShellScript.sh.如果您只是从开始打开cmd,并键入该行,它将执行.如果您只是双击该文件,它也可以完美运行.但是,从VSCode启动时,此输出只会挂起,直到我终止它.
尝试2号:
{
"version": "0.1.0",
"command": "cmd",
"isShellCommand": true,
"args": [ "bash myShellScript.sh" ],
"showOutput": "always"
}
Run Code Online (Sandbox Code Playgroud)
这也像上面一样挂起.
尝试3号:
{
"version": "0.1.0",
"command": "C:/Windows/System32/bash",
"isShellCommand": false,
"args": [ "myShellScript.sh" ],
"showOutput": "always"
}
Run Code Online (Sandbox Code Playgroud)
这给了我:
Failed to launch external program C:/Windows/System32/bash myShellScript.sh
spawn C:/Windows/System32/bash ENOENT
Run Code Online (Sandbox Code Playgroud)
我也尝试过"isShellCommand"在某些情况下将变量设置为true和false,但无济于事.
有谁知道如何做到这一点?
我也想看看我怎么能做同样的事情.
andlrc - 我已经尝试了你的两个选项,他们似乎都没有做到这一点.问题似乎是在Visual Studio Code运行它的任何上下文中都无法识别bash.我尝试过各种方法:
如果我有所作为,我会继续尝试并回复.
编辑:知道了.相信这个男人 - https://aigeec.com/using-windows-10-anniversary-bash-with-visual-studio-code/
总之,它归结为我在64位操作系统上,这意味着bash.exe位于C:\ Windows\System32.一旦我按照博客文章的建议将bash.exe复制到SysWOW64中,Visual Studio Code的默认构建操作(Ctrl + Shift + B)就会按照您的预期运行.
这看起来有点像一个hacky解决方法 - 它可能值得用MSFT提高,看看我们能做些什么.
编辑:这是我的tasks.json按要求:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"command": "bash",
"isShellCommand": true,
"args": [ "./gulp.sh" ],
"showOutput": "always",
"tasks": [{
"taskName": "scripts",
"isBuildCommand": true,
"problemMatcher": "$gulp-tsc",
"isWatching": true
}]
Run Code Online (Sandbox Code Playgroud)
}
gulp.sh只包含一个命令; 'gulp':-)但你基本上可以把你想要的东西放在那里,我想你可以有几个.sh脚本来满足不同的任务磁带
为了回应Sysnative的使用,遗憾的是它似乎并不理解,并且构建任务没有运行.
| 归档时间: |
|
| 查看次数: |
12538 次 |
| 最近记录: |