✅ How to read Environment Variables in VS Code ?
Edit. Solved. Code was correct, but had to run from ".NET Core Launch (Console)" and not from "Debug project associated with this file"
Using .Net 8.0.402 and Visual Studio Code 1.94.0
I'm trying to get pretty simply a value from a file named launch.json in .vscode folder. The path is:
.vscode\launch.json
and the path of the file I'm calling from is:
Program.cs
Program.cs has:
private static void Main(string[] args)
{
string a = Environment.GetEnvironmentVariable("API_ENDPOINT");
And the launch.json has:
{
"version": "0.2.0",
"configurations": [
{
...
"env": {
"API_ENDPOINT": "europe-west2-aiplatform.googleapis.com",
And string a gets a value of null. What's the correct way to receive it?
I feel like this is something very, very simple to solve.
Using .Net 8.0.402 and Visual Studio Code 1.94.0
I'm trying to get pretty simply a value from a file named launch.json in .vscode folder. The path is:
.vscode\launch.json
and the path of the file I'm calling from is:
Program.cs
Program.cs has:
private static void Main(string[] args)
{
string a = Environment.GetEnvironmentVariable("API_ENDPOINT");
And the launch.json has:
{
"version": "0.2.0",
"configurations": [
{
...
"env": {
"API_ENDPOINT": "europe-west2-aiplatform.googleapis.com",
And string a gets a value of null. What's the correct way to receive it?
I feel like this is something very, very simple to solve.