Yux*_*ang 17 visual-studio-code windows-subsystem-for-linux vscode-tasks
我尝试为将在 Windows 子系统 Linux 中运行的 Visual Studio Code 任务设置环境变量。然而,它似乎不起作用。这是我的tasks.json:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "test env",
"type": "shell",
"command": "echo",
"args": [
"$test"
],
"options": {
"env": {
"test": "test_string"
}
}
},
]
}
Run Code Online (Sandbox Code Playgroud)
输出是:
> Executing task in folder ex12-test: echo $test <
Terminal will be reused by tasks, press any key to close it.
Run Code Online (Sandbox Code Playgroud)
请注意,默认情况下 shell 已手动修改为C:\WINDOWS\SysNative\bash.exeWSL,如此处和此处的建议。
Mar*_*ark 19
选项对象超出任何任务,因此:
format
"version": "2.0.0",
"options": {
"env": {
"test": "test_string"
}
}
"tasks": [
{
"label": "test env",
"type": "shell",
"command": "echo",
"args": [
"$env:test"
],
},
Run Code Online (Sandbox Code Playgroud)
然后访问选项参数,如下所示:
$env:test or ${env:test}
]
Run Code Online (Sandbox Code Playgroud)
我最终为 VS Code (v1.67.1) 所做的是:
settings.json%ENV_VAR%选项。所以在 中settings.json,创建这个:
{
"terminal.integrated.env.windows": { // switch to your os, check `Open Workspace Settings` in the Command Pallete then search for `environment`
"AWS_REGION": "us-east-2",
"AWS_ID": "my_id"
}
}
Run Code Online (Sandbox Code Playgroud)
在 中tasks.json,使用正确的 ENV 变量引用:
"command": "echo %AWS_REGION%"
| 归档时间: |
|
| 查看次数: |
29676 次 |
| 最近记录: |