有没有办法在 Visual Studio Code 中设置环境变量? [英] Is there any way to set environment variables in Visual Studio Code?
问题描述
你能帮我看看如何在visual studio代码中设置环境变量吗?
Could you please help me, how to setup environment variables in visual studio code?
推荐答案
假设您的意思是调试会话(?),那么您可以在 启动配置.
Assuming you mean for a debugging session(?) then you can include a env
property in your launch configuration.
如果您在工作区中打开 .vscode/launch.json 文件或选择调试 >打开配置,然后您应该会看到一组用于调试代码的启动配置.然后,您可以向其中添加一个带有字符串字典的 env
属性:字符串.
If you open the .vscode/launch.json file in your workspace or select Debug > Open Configurations then you should see a set of launch configurations for debugging your code. You can then add to it an env
property with a dictionary of string:string.
以下是 ASP.NET Core 应用程序的示例,该应用程序的标准 Web 模板将 ASPNETCORE_ENVIRONMENT
设置为 Development
:
Here is an example for an ASP.NET Core app from their standard web template setting the ASPNETCORE_ENVIRONMENT
to 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 中设置环境变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!