Issue
I have a launchSettings.json file and some Docker environmentVariables. I attempted to pull one of the settings using GetEnvironmentVariable, and it doesn't seem to be working.
string strTest = Environment.GetEnvironmentVariable("TESTING");
Console.WriteLine($"Docker Env Test: {strTest}");
It isn't returning anything. I've searched around and the GetEnvironmentVariable seems to be the way to do it, but it's only returning variables from ProgC.
launchSettings.json
{
"profiles": {
"ProgC": {
"commandName": "Project",
"environmentVariables": {
"IsDev": "1",
"JobName": "ProgC",
"Environment": "TEST"
}
},
"Docker": {
"commandName": "Docker",
"environmentVariables": {
"IsDev": "1",
"JobName": "ProgC",
"AppID": "372011",
"ConfigurationID": "1",
"Environment": "TEST",
"TESTING": " Yup"
}
}
}
}
Solution
I'm going to make the assumption that you're doing this from within Visual Studio.
You need to make sure you're selecting the correct build properties when you run/publish your app. I'm also going to assume that at present, ProgC
is selected and needs to be changed.
That will ensure it's pointing to the right profile and it will then pull your environment variables as you have defined.
Answered By - Skin Answer Checked By - Katrina (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.