如何在VSCode中将环境变量添加到launch.json [英] How do I add environment variables to launch.json in VSCode

查看:1792
本文介绍了如何在VSCode中将环境变量添加到launch.json的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在node.js项目上使用新的VSCode编辑器.我正在尝试通过编辑launch.json文件来配置启动"配置文件以进行调试.我需要将连接字符串设置为环境变量.根据launch.json文件中的注释:

Working with the new VSCode editor on a node.js project. I am attempting to configure my "Launch" profile for debugging by editing the launch.json file. I need to setup a connectionstring as an environment variable. According to the comments in the launch.json file:

// Environment variables passed to the program.
"env": { }

我尝试像这样添加我的环境变量:

I have tried adding my environment variable like so:

"env":
{
"CONNECTION_STRING": "Data Source=server;Initial Catalog=catalog;User ID=uid;Password=pwd;MultipleActiveResultSets=true"
}

当我尝试启动我的应用程序时,这会导致错误; "OpenDebug进程意外终止".我尚未找到任何可以解释问题根源的日志文件等.

This causes an error when I try to launch my app; "OpenDebug process has terminated unexpectedly". I have not yet found any log files, etc. that might explain what the issue is.

当我设置环境变量并从标准命令提示符启动我的应用程序时,我知道此应用程序可以正常工作.如果我在launch.json文件中注释掉变量,该应用程序还将按预期运行;我只是无法连接到数据库.

I know this app works correctly when I setup the environment variable and launch my app from the standard command prompt. The app also runs as expected if I comment out my variable in the launch.json file; I just can't connect to the database.

我假设我在launch.json文件中使用了错误的格式,但是我还没有找到任何使之有效的方法.

I am assuming that I am using the wrong format in the launch.json file, but I have not yet found any way to make this work.

有什么想法吗?

推荐答案

Windows(可能是Linux)上的环境变量似乎存在问题.它确实可以在OS X上运行.我们正在调查中.期待尽快修复.

There seems to be a problem with environment variables on Windows (and probably on linux). It does work on OS X. We are investigating. Expect a fix soon.

安德烈·韦南(Andre Weinand),
Visual Studio代码

Andre Weinand,
Visual Studio Code

更新(2015年6月2日): Visual Studio Code 0.3.0包含针对此问题的修复程序.

Update (June 2, 2015): Visual Studio Code 0.3.0 contains a fix for this.

这篇关于如何在VSCode中将环境变量添加到launch.json的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆