问题描述
我怎么可以运行从Visual Studio code在Windows猛砸作为运行的任务吗?
how can I run the Windows Bash from Visual Studio code as a run task?
下面是一些我多次尝试在 tasks.json
来做到这一点。
Here are some of my many attempts at tasks.json
to do this.
{
"version": "0.1.0",
"command": "cmd",
"isShellCommand": true,
"args": [ "RunShellScript.bat" ],
"showOutput": "always"
}
RunShellScript.bat只有这一行:庆典myShellScript.sh
。这意味着,如果你从开始只需打开cmd,然后键入该行,它将执行。它还可以运行完美,如果你只是双击该文件也是如此。然而,从VS code启动时,这个输出只是挂起,直到我终止。
RunShellScript.bat has only this line: bash myShellScript.sh
. Which if you just open cmd from start, and type that line, it will execute. It also runs perfectly if you just double click the file as well. However, when launched from VSCode, this output just hangs until I terminate it.
尝试数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
变量真假的一些案件,但无济于事。
Ive also experimented with setting the "isShellCommand"
variable to true and false in some of these cases, but to no avail.
有谁知道如何做到这一点?
Does anyone know how to do this?
推荐答案
我也被想看看我怎么可能做同样的事情。
I too was looking to see how I could do the same thing.
andlrc - 我想你两个选择和他们都不似乎做的伎俩。这个问题似乎是在庆典在任何情况下适当的Visual Studio code运行它无法识别我已经试过各种方法:
andlrc - I've tried your two options and neither of them seem to do the trick. The issue seems to be in that bash is not recognised in whatever context Visual Studio Code runs it in. I've tried various approaches:
- 命令:C:/Windows/System32/bash.exe
- 命令:庆典
- 命令:bash.exe
我会继续努力和后回来,如果我得到的东西的工作。
I'll keep trying and post back if I get something working.
修改:知道了。感谢这个人 -
Edit: Got it. Credit to this man - 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)上运行,你希望它。
In summary, what it boils down to is that I am on a 64 bit operating system which means bash.exe is located in C:\Windows\System32. Once i'd copied bash.exe into SysWOW64 as the blog post suggests, the default build action (Ctrl+Shift+B) of Visual Studio Code runs as you'd expect it to.
这似乎有点哈克变通办法的 - 它可能是值得MSFT提高,看看是否有什么东西,我们可以做些什么
This seems a bit of a hacky workaround - it's probably worth raising with MSFT to see if there's something we can do about it.
修改:这是按要求我tasks.json:
Edit: Here's my tasks.json as requested:
{
// 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
}]
}
gulp.sh只包含一个命令; '吞掉':-)但你可以把实质上无论你在那里想,我想你可以有几个.SH脚本,以满足任务的不同的磁带
gulp.sh contains only one command; 'gulp' :-) but you could essentially put whatever you want in there, I suppose you could have several .sh scripts to cater for the different tapes of tasks
在应对使用Sysnative的,遗憾的是它似乎并不明白这一点,构建任务不会运行。
In response to the use of Sysnative, unfortunately it doesn't seem to understand that and the build task does not run.
这篇关于窗户Bash和Visual Studio的code:我怎样才能启动bash作为一个运行的任务吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!