我试图在 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 …