Tri*_*ner 8 c# environment-variables visual-studio-code vscode-tasks
我正在尝试tasks.json在vscode.
在我的launch.json文件中,我有以下代码来解析 .env 文件:
"configurations": [
{
...
"envFile": "${workspaceFolder}/.env",
}
]
Run Code Online (Sandbox Code Playgroud)
然后我在文件中包含tasks.json此任务:
{
"label": "login",
"command": "sh",
"type": "shell",
"args": [
"${workspaceFolder}/etc/login.sh",
"${env:USERNAME}",
"${env:PASSWORD}"
]
}
Run Code Online (Sandbox Code Playgroud)
这似乎是https://code.visualstudio.com/docs/editor/tasks隐含的代码,但是(通过在另一个任务中回显进行测试)我发现最后两个args是空白的。经过在线研究后,我想我找到了原因,它们configurations..env是由它们tasks自己使用的,而不是由task.json运行访问的,因此无法访问。
我如何env variables在 中创建(使用)这些tasks.json?
查看https://code.visualstudio.com/docs/editor/tasks-appendix
/**
* The environment of the executed program or shell. If omitted
* the parent process' environment is used.
*/
env?: { [key: string]: string };
Run Code Online (Sandbox Code Playgroud)
例子
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "diagnostic",
"type": "shell",
"options": {
"cwd": "${workspaceFolder}/beam",
"env": {
"FOO": "baz",
}
},
"command": "printenv",
"problemMatcher": []
}
]
}
Run Code Online (Sandbox Code Playgroud)
我不知道如何从像 launch.json 这样的文件中提取这些内容
我会在 vscode 存储库上打开一个问题
| 归档时间: |
|
| 查看次数: |
5679 次 |
| 最近记录: |