gpt4 book ai didi

visual-studio-code - 有没有办法在 Visual Studio Code 中设置环境变量?

转载 作者:行者123 更新时间:2023-12-03 07:27:32 28 4
gpt4 key购买 nike

如何在 Visual Studio Code 中设置环境变量?

最佳答案

假设您的意思是调试 session (?),那么您可以在 launch configuration 中包含 env 属性.

如果您在工作区中打开 .vscode/launch.json 文件或选择“调试”>“打开配置”,那么您应该会看到一组用于调试代码的启动配置。然后,您可以向其中添加一个包含 string:string 字典的 env 属性。

以下是 ASP.NET Core 应用的示例,其标准 Web 模板将 ASPNETCORE_ENVIRONMENT 设置为 Development:

{
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/bin/Debug/netcoreapp2.0/vscode-env.dll",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
"internalConsoleOptions": "openOnSessionStart",
"launchBrowser": {
"enabled": true,
"args": "${auto-detect-url}",
"windows": {
"command": "cmd.exe",
"args": "/C start ${auto-detect-url}"
},
"osx": {
"command": "open"
},
"linux": {
"command": "xdg-open"
}
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sourceFileMap": {
"/Views": "${workspaceFolder}/Views"
}
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
]
}

关于visual-studio-code - 有没有办法在 Visual Studio Code 中设置环境变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48595446/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com