microsoft / microsoft/vscode-dotnettools
Restart does not rebuild when a launch config specifies a custom preLaunchTask (gap in the #496 fix)
Nobody has claimed this yet.
- Dominant language
- No language data
- Stars
- 321
- Forks
- 54
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 2
Description
Summary
Since the fix for #496 (C# Dev Kit v1.2.2), pressing Restart in a debug session rebuilds the project on restart — but only when the launch configuration has no preLaunchTask. If a dotnet launch configuration specifies its own preLaunchTask, Restart no longer rebuilds: it re-spins the previously-built binary and source-code changes are silently ignored. Stopping and starting the session (Stop → Start) rebuilds correctly.
The implicit build that the #496 fix runs on restart appears to be carried by the default/implicit pre-launch step; a user-supplied preLaunchTask replaces it, so the build is dropped from the restart path.
Environment
- C# Dev Kit: v3.20.199 (win32-x64)
- C# extension: v2.140.9
- VS Code: 1.129.1
- .NET SDK: 10.0.302
- OS: Windows 11
Repro
launch.json:
{
"type": "dotnet",
"request": "launch",
"name": "Launch API",
"projectPath": "${workspaceFolder}/src/Web.Api/Web.Api.csproj",
"preLaunchTask": "noop" // any task that does NOT build, e.g. an `echo`
}
- F5 to start; confirm it runs.
- Edit code so observable output changes (e.g. a returned string).
- Press Restart (⟳ / Ctrl+Shift+F5).
Actual: the old binary is relaunched; the code change is not applied.
Expected: the project is rebuilt on restart (as it is when no preLaunchTask is present, and as Stop → Start does).
Confirmation that the preLaunchTask is the trigger: removing the preLaunchTask line (or using the auto-generated C#: <project> dynamic configuration, which has none) makes Restart rebuild correctly.
Analysis
VS Code core's restartSession runs runTasks() and then issues a DAP restart to the adapter when it advertises supportsRestartRequest:
if (session.capabilities.supportsRestartRequest) {
const taskResult = await runTasks();
if (taskResult === TaskRunResult.Success) {
await doRestart(async () => {
await session.restart();
return true;
});
}
return;
}
So on restart the only build opportunity is whatever runs inside runTasks(). With no preLaunchTask, the Dev Kit's implicit build runs there (the #496 fix); a user preLaunchTask replaces it, so nothing builds and the adapter re-spins the stale binary. This is consistent with #1822 ("restarts … resubmit the existing launch.json … there should be a way for us to reload … if we know it's a restart").
Suggested fix
On restart, run the implicit build even when a user preLaunchTask is specified — e.g. compose the implicit build with the user's tasks, or trigger the build inside the restart handler — so that adding a custom preLaunchTask doesn't silently disable the rebuild. At minimum, document that a custom preLaunchTask on a dotnet configuration must itself perform the build.
Related
- #496 — fixed the no-
preLaunchTaskcase (v1.2.2) - #615 — closed as duplicate of #496
- #1822 — restart resubmits the existing config
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with VS Code's src/vs/workbench/contrib/debug/browser/debugService.ts and trace runTasks() for restartSession, then inspect the Dev Kit handling of implicit builds and custom preLaunchTask values. Reproduce with the supplied launch.json and a changed observable output. Done means Restart rebuilds before relaunching even when a non-building preLaunchTask is configured, without regressing Stop → Start or configurations without preLaunchTask.
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
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100