Use semicolon in environment variable

Jul 30, 2014 at 5:03 PM
I would like to set up an environment variable that contains a semicolon, but this doesn't seem to work currently since the semicolon is interpreted as a delimiter.

For example:

EDGE_SQL_CONNECTION_STRING=Data Source=localhost;Initial Catalog=foo

Here, the value of the environment variable is truncated to "Data Source=localhost"

Is it possible to escape the semicolon?
Coordinator
Jul 30, 2014 at 6:31 PM
Edited Jul 30, 2014 at 6:32 PM
It's happening because environment variables are stored semicolon-separated in the .njsproj file. Looking at the code, we don't provide any means to escape the semicolon there:
        private IEnumerable<KeyValuePair<string, string>> GetEnvironmentVariables() {
            var envVars = _project.GetProjectProperty(NodejsConstants.EnvironmentVariables);
            if (envVars != null) {
                foreach (var envVar in envVars.Split(';')) {
                    var nameValue = envVar.Split(new[] { '=' }, 2);
                    if (nameValue.Length == 2) {
                        yield return new KeyValuePair<string, string>(nameValue[0], nameValue[1]);
                    }
                }
            }
        }
C++ project system, which has a similar feature, uses newlines instead. We should consider doing the same thing.
Coordinator
Jul 30, 2014 at 6:33 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.