[VS Code] Configure launch.json targets the first workspace folder instead of the selected AppHost
- Dominant language
- C#
- Stars
- 6.3k
- Forks
- 991
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 196
Description
### Is there an existing issue for this?
- [x] I have searched the existing issues
### Describe the bug
The **Aspire: Configure launch.json file** command always writes `.vscode/launch.json` under the first entry in `vscode.workspace.workspaceFolders` and generates an Aspire configuration with:
```json
"program": "${workspaceFolder}"
```
The command does not use the active, selected, or uniquely discovered AppHost. In a multi-root workspace, it can therefore write the configuration into a folder that does not contain the AppHost. When multiple AppHosts are available, the generated configuration also does not persist which one the user intended to launch.
### Expected Behavior
The command should discover the buildable AppHosts available in the workspace and resolve the launch target before writing the configuration:
- If exactly one AppHost is available, select it automatically.
- If multiple AppHosts are available, prompt the user to select one.
- Honor an active or persisted AppHost selection where applicable.
- Write `launch.json` under the selected AppHost's workspace folder.
- Set `program` to the selected AppHost's concrete workspace-relative path, such as `${workspaceFolder}/apphost/MyAppHost.csproj`.
- Leave files unchanged if the selection is cancelled.
- Preserve the existing dashboard-launch behavior prompt.
### Steps To Reproduce
1. Open a multi-root VS Code workspace whose first folder does not contain an AppHost and whose second folder does.
2. Run **Aspire: Configure launch.json file** from the command palette.
3. Select a dashboard launch behavior.
4. Inspect the generated configuration.
The command creates `.vscode/launch.json` under the first workspace folder and sets `program` to `${workspaceFolder}` instead of targeting the discovered AppHost in the second folder.
### Exceptions (if any)
None.
### Aspire doctor output
N/A
### Anything else?
N/A
Contributor guide
Research direction
Start at the implementation of the “Aspire: Configure launch.json file” command and trace its use of vscode.workspace.workspaceFolders and AppHost discovery. Done means selecting the sole or prompted AppHost, writing launch.json beneath its workspace folder with its concrete path, preserving the dashboard prompt, and making no changes when selection is cancelled.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, vscode
- Domain
- developer-experience, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100