dotnet / dotnet/sdk

`launchSettings.json` environment variables are not propagated for `commandName: Executable`

Open
#56,023 0 comments 1 reaction 2 assignees Claimed by @marcpopMSFT View on GitHub
needs team triage untriaged
Dominant language
C#
Stars
3.2k
Forks
1.3k
PR merge metrics
PR metrics pending

Description

### Describe the bug

Environment variables defined in `launchSettings.json` are not propagated to the application when running through Builder/App.

The issue is reproducible in both Builder and App and for `Environment.GetEnvironmentVariable()`.

### Steps to reproduce

1. git clone https://github.com/PatrykKuniczak/EnvDotNetRepro.git
2. Open `Properties/launchSettings.json`
3. Run each one profile and see results in console.

### Expected behavior

For all profiles `ASPNETCORE_ENVIRONMENT` should work as described in "environmentVariables"

### Actual behavior

If `commandName` is "Executable" and probably other option than "Project"(I've tested only "Executable")
`environmentVariables` isn't recognized in program/runtime and `ASPNETCORE_ENVIRONMENT` is "Production"(I think it's default).

Output of "Watch" profile:
Image

### Is this a regression?

Maybe that's related: https://github.com/dotnet/sdk/issues/49131

### Are there any workarounds?

I've been watching for workaround, for now i've overwriten:
```c#
Environment.SetEnvironmentVariable("ASPNETCORE_ENVIRONMENT", "Development");
```

### dotnet --info output

```console
.NET SDK:
Version: 10.0.400
Commit: 14fbf8d527
Workload version: 10.0.400-manifests.330ea142
MSBuild version: 18.9.6+14fbf8d52

Środowisko uruchomieniowe:
OS Name: Mac OS X
OS Version: 26.6
OS Platform: Darwin
RID: osx-arm64
Base Path: /opt/homebrew/Cellar/dotnet/10.0.400/libexec/sdk/10.0.400/

Zainstalowane obciążenia platformy .NET:
Brak zainstalowanych obciążeń do wyświetlenia.
Skonfigurowano używanie workload sets podczas instalowania nowych manifestów.
Nie zainstalowano żadnych zestawów obciążeń. Uruchom „dotnet workload restore”, aby zainstalować zestaw obciążeń.

Host:
Version: 10.0.11
Architecture: arm64
Commit: e2f47b0110

.NET SDKs installed:
10.0.400 [/opt/homebrew/Cellar/dotnet/10.0.400/libexec/sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 10.0.11 [/opt/homebrew/Cellar/dotnet/10.0.400/libexec/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 10.0.11 [/opt/homebrew/Cellar/dotnet/10.0.400/libexec/shared/Microsoft.NETCore.App]

Other architectures found:
None

Environment variables:
DOTNET_ROOT [/opt/homebrew/Cellar/dotnet/10.0.400/libexec]

global.json file:
Not found

But it works(really not work) the same on Windows
```

### IDE version

JetBrains Rider 2026.2.1

### Other details

Another interesting thing is "hotReloadEnabled": true for "Dev" profile, doesn't enable it/doesn't work.
I can edit "Program.cs" and nothing happened, restart/hot reload works only when i use "dotnet watch".
That's why "Watch" profile is sooo crucial for me, without that development isn't that good as it could be.

I really hope somebody can help me quickly, maybe i've done sth wrong.
If not then, i'm thrilled to see a patch for that bug, because now i need to manually comment line where i set env to "Development" to see "Production" result.

Cheers ❤️

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.