有什么方法可以在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
属性,该属性具有string:string字典.
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
:
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"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屋!