虽然其他问题涉及如何使用像git-bash这样的东西,但是给新的WSL一个旋转,因为VS Code的终端不一样:它让你可以访问在实际的Ubuntu Linux子系统上运行的bash,而不是git-在Windows子系统上运行的bash终端.
那么我们如何让它作为VS Code终端工作,特别是我们如何让它作为功能开发环境终端工作呢?
与git-bash不同,遗憾的是,这不是那么简单,因为WSL中的Ubuntu Linux配置可以提供一些陷阱,例如NPM尝试(和失败)从Windows Program Files目录运行,因为WSL和Windows本身之间的交互路径的条款,以及一些像Compass这样的软件包失败的原因并不一定是那些不习惯在Linux上开发的人的明显原因.为VS Code提供可靠的WSL终端环境的简单方法是什么?在通过apt-get或安装时最常用的工具将运行npm?
git bash ubuntu visual-studio-code windows-subsystem-for-linux
我试图在 VSCode 的tasks.json 中定义我自己的环境变量。根据到目前为止我找到的每个链接,我尝试了以下操作:
{
"version": "2.0.0",
"type": "shell",
"options": {
"env": {
"APP_NAME": "myApp"
}
},
"problemMatcher": {
"owner": "cpp",
"fileLocation": [
"relative",
"${workspaceFolder}"
],
"pattern": {
"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
},
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "dedicated",
"showReuseMessage": false
},
"tasks": [
{
"label": "Build Release",
"command": "python ./scripts/build_app.py $APP_NAME",
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
Run Code Online (Sandbox Code Playgroud)
我需要这个,因为我们正在通过 python 脚本运行构建过程,因此我需要给它我想要构建的应用程序的名称。由于我还有用于测试、执行、调试等的 python 脚本,因此我更愿意在tasks.json …