0

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"
      }
    }
  }
}
0

1 Answer 1

1

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.

Build

That will ensure it's pointing to the right profile and it will then pull your environment variables as you have defined.

Sign up to request clarification or add additional context in comments.

1 Comment

Fantastic, thank you. Yeah, nothing I found talked about changing that, having to install Linux Kernels, etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.