dotnet / dotnet/vscode-csharp

launch.json does not pickup a seondary launchConfigurationId from Properties/launchSettings.JSON

Open
#7,584 22 comments 8 reactions 1 assignee Claimed by @WardenGnaw View on GitHub
Debugger
Dominant language
TypeScript
Stars
3.1k
Forks
737
Avg merge
18h 40m
Merged PRs (30d)
31

Description

Trying to debug an application using different environment variables for the use use of appSettings.env.json i.e.:
```
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
```
does not pick up a secondary profile. So I can have a Development env and a UAT env but it only picks up the first one when I hit debug. Same thing happens on Compounds:

launch.json sample:
```
{
"version": "0.2.0",
"configurations": [
{
"name": "MyAppDev",
"type": "dotnet",
"request": "launch",
"projectPath": "${workspaceFolder}/MyApp/MyApp.csproj",
"launchConfigurationId": "TargetFramework=;MyAppDev"
},
{
"name": "MyAppUAT",
"type": "dotnet",
"request": "launch",
"projectPath": "${workspaceFolder}/MyApp/MyApp.csproj",
"launchConfigurationId": "TargetFramework=;MyAppUAT"
},
]
}
```

LaunchSettings.Json sample:
```
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"profiles": {
"MyAppDev": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "clients",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
},
"applicationUrl": "https://localhost:44334"
}
"MyAppUAT": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "clients",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "UAT",
},
"applicationUrl": "https://localhost:44334"
}
}
}
```

If the `CSharp: Report an issue` command doesn't appear, make sure that you have C# extension version 1.17.0 or newer installed.
## Environment data
VS Code version: 1.93.1 (Universal)
C# Extension version: current latest and Pre-release versions

## Steps to reproduce
1. go to Debug
2. select profile 1, run, it loads c# app on development.
3. select profile 2, run, it loads c# app still on development instead of UAT

## Expected behavior
the UI will pick the correct profile to launch

## Additional context
This was working on a few versions ago, but I didnt had to use vscode on this project for a while until recently that realized it was not picking up my other environments.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.