© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•17mo ago•
14 replies
Arto Kilponen

✅ 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.
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ Environment variables in tests
C#CC# / help
3y ago
✅ How to setup environment variables in Azure Web App
C#CC# / help
11mo ago
how to setup C# in VS code
C#CC# / help
2y ago
❔ Environment variables vs configuration files for storing secrets
C#CC# / help
3y ago