Feature request: integrate debugging with `dotnet watch`
See original GitHub issueIssue Description
Hi, im currently trying to set-up vscode in such a way that I can use both the debugger and dotnet watch run
. When running dotnet watch run
it spawns a new process eg weather.exe
which the debugger can attach to. When you trigger a recompile however, dotnet watch run
terminates the process weather.exe
causing the debugger to also exit. This means that we have to restart the debugger every time the app is recompiled, which defeats the purpose of using dotnet watch
in the first place.
I would suggest a configurable timeout for the debugger to give time to reattach to the previous instance once it gets detached.
I’ve attached launch.json
, tasks.json
and the log of my terminal after reloads, I’ve also included a repository down below.
Launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Attach",
"type": "coreclr",
"preLaunchTask": "watch",
"request": "attach",
"processName": "weather.exe"
}
]
}
Tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"${workspaceFolder}/weather.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile",
"isBackground": true
}
]
}
dotnet watch run log
watch : Started Building… info: Microsoft.Hosting.Lifetime[14] Now listening on: https://localhost:7081 info: Microsoft.Hosting.Lifetime[14] Now listening on: http://localhost:5177 info: Microsoft.Hosting.Lifetime[0] Application started. Press Ctrl+C to shut down. info: Microsoft.Hosting.Lifetime[0] Hosting environment: Development info: Microsoft.Hosting.Lifetime[0] Content root path: C:\Users\Niels\source\repos\dotnet-watch-attach watch : Exited watch : File changed: C:\Users\Niels\source\repos\dotnet-watch-attach\Controllers\WeatherForecastController.cs watch : Started Building… info: Microsoft.Hosting.Lifetime[14] Now listening on: https://localhost:7081 info: Microsoft.Hosting.Lifetime[14] Now listening on: http://localhost:5177 info: Microsoft.Hosting.Lifetime[0] Application started. Press Ctrl+C to shut down. info: Microsoft.Hosting.Lifetime[0] Hosting environment: Development info: Microsoft.Hosting.Lifetime[0] Content root path: C:\Users\Niels\source\repos\dotnet-watch-attach watch : Exited watch : File changed: C:\Users\Niels\source\repos\dotnet-watch-attach\Controllers\WeatherForecastController.cs watch : Started Building… info: Microsoft.Hosting.Lifetime[14] Now listening on: https://localhost:7081 info: Microsoft.Hosting.Lifetime[14] Now listening on: http://localhost:5177 info: Microsoft.Hosting.Lifetime[0] Application started. Press Ctrl+C to shut down. info: Microsoft.Hosting.Lifetime[0] Hosting environment: Development info: Microsoft.Hosting.Lifetime[0] Content root path: C:\Users\Niels\source\repos\dotnet-watch-attach
Steps to Reproduce
Repository to reproduce: here
Launch the configuration: .NET Core Attach
Expected Behavior
Debugger stays attached
Actual Behavior
Debugger gets terminated as dotnet watch run
terminates the process it is attached to.
Logs
OmniSharp log
OmniSharp server started. Path: c:\Users\Niels.vscode\extensions\ms-dotnettools.csharp-1.23.16.omnisharp\1.37.16\OmniSharp.exe PID: 12536
Starting OmniSharp on Windows 6.2.9200.0 (x64)
Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK
Using the 'dotnet' on the PATH.
DotNetPath set to dotnet
Located 2 MSBuild instance(s)
1: Visual Studio Enterprise 2019 16.10.31424.327 16.10.2 - "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin"
2: StandAlone 17.0.0 - "c:\Users\Niels\.vscode\extensions\ms-dotnettools.csharp-1.23.16\.omnisharp\1.37.16\.msbuild\Current\Bin"
Registered MSBuild instance: Visual Studio Enterprise 2019 16.10.31424.327 16.10.2 - "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin"
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionOptionsProvider, Order: 0
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.RenameWorkspaceOptionsProvider, Order: 100
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.ImplementTypeWorkspaceOptionsProvider, Order: 110
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.BlockStructureWorkspaceOptionsProvider, Order: 140
Detecting Cake files in 'c:\Users\Niels\source\repos\dotnet-watch-attach'.
Could not find any Cake files
No solution files found in 'c:\Users\Niels\source\repos\dotnet-watch-attach'
Queue project update for 'c:\Users\Niels\source\repos\dotnet-watch-attach\weather.csproj'
Detecting CSX files in 'c:\Users\Niels\source\repos\dotnet-watch-attach'.
Could not find any CSX files
Configuration finished.
Omnisharp server running using Stdio at location 'c:\Users\Niels\source\repos\dotnet-watch-attach' on host 15580.
Loading project: c:\Users\Niels\source\repos\dotnet-watch-attach\weather.csproj
Targeting .NET 6.0 in Visual Studio 2019 is not supported.
Successfully loaded project file 'c:\Users\Niels\source\repos\dotnet-watch-attach\weather.csproj'.
c:\Users\Niels\source\repos\dotnet-watch-attach\weather.csproj C:\Program Files\dotnet\sdk\6.0.100-rc.2.21505.57\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.DefaultItems.targets(134,5): Error: Targeting .NET 6.0 in Visual Studio 2019 is not supported.
Adding project 'c:\Users\Niels\source\repos\dotnet-watch-attach\weather.csproj'
Update project: weather
Received response for /v2/getcodeactions but could not find request.
C# log
VSCode version: 1.61.0 C# Extension: 1.23.16
Dotnet Information
.NET SDK (reflecting any global.json): Version: 6.0.100-rc.2.21505.57 Commit: ab39070116Runtime Environment: OS Name: Windows OS Version: 10.0.19043 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\6.0.100-rc.2.21505.57\
Host (useful for support): Version: 6.0.0-rc.2.21480.5 Commit: 6b11d64e7e
.NET SDKs installed: 2.0.2 [C:\Program Files\dotnet\sdk] 2.1.2 [C:\Program Files\dotnet\sdk] 2.1.201 [C:\Program Files\dotnet\sdk] 2.1.202 [C:\Program Files\dotnet\sdk] 2.1.300 [C:\Program Files\dotnet\sdk] 2.1.526 [C:\Program Files\dotnet\sdk] 3.1.120 [C:\Program Files\dotnet\sdk] 3.1.414 [C:\Program Files\dotnet\sdk] 5.0.104 [C:\Program Files\dotnet\sdk] 5.0.301 [C:\Program Files\dotnet\sdk] 5.0.303 [C:\Program Files\dotnet\sdk] 6.0.100-rc.1.21458.32 [C:\Program Files\dotnet\sdk] 6.0.100-rc.2.21505.57 [C:\Program Files\dotnet\sdk]
.NET runtimes installed: Microsoft.AspNetCore.All 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.28 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.28 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.16 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.0-rc.2.21480.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.28 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.16 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.0-rc.2.21480.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.1.16 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 3.1.20 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.0-rc.2.21501.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
To install additional .NET runtimes or SDKs: https://aka.ms/dotnet-download
Visual Studio Code Extensions
Extension | Author | Version |
---|---|---|
azure-account | ms-vscode | 0.9.9 |
azure-pipelines | ms-azure-devops | 1.191.0 |
azurerm-vscode-tools | msazurermtools | 0.15.4 |
azurite | Azurite | 3.14.2 |
beautify | HookyQR | 1.5.0 |
bracket-pair-colorizer-2 | CoenraadS | 0.2.1 |
chat | karigari | 0.35.0 |
clang-format | xaver | 1.9.0 |
cpptools | ms-vscode | 1.7.0 |
csharp | ms-dotnettools | 1.23.16 |
debugger-for-edge | msjsdiag | 1.0.15 |
discord-vscode | icrawl | 5.7.0 |
EditorConfig | EditorConfig | 0.16.4 |
gc-excelviewer | GrapeCity | 3.0.44 |
githistory | donjayamanne | 0.6.18 |
github-vscode-theme | GitHub | 5.0.0 |
java | redhat | 0.82.0 |
jupyter | ms-toolsai | 2021.9.1001312534 |
jupyter-keymap | ms-toolsai | 1.0.0 |
jupyter-renderers | ms-toolsai | 1.0.3 |
ng-template | Angular | 12.2.1 |
tomoki1207 | 1.1.0 | |
powershell | ms-vscode | 2021.10.0 |
prettier-vscode | esbenp | 9.0.0 |
python | ms-python | 2021.10.1336267007 |
rainbow-csv | mechatroner | 1.9.1 |
remote-containers | ms-vscode-remote | 0.202.4 |
remote-ssh | ms-vscode-remote | 0.65.8 |
remote-ssh-edit | ms-vscode-remote | 0.65.8 |
remote-wsl | ms-vscode-remote | 0.58.2 |
shadered | dfranx | 0.0.5 |
shaderlabformatter | litefeel | 0.4.1 |
shaderlabvscodefree | amlovey | 1.2.8 |
unity-debug | Unity | 3.0.2 |
vetur | octref | 0.34.1 |
vscode-azurefunctions | ms-azuretools | 1.5.2 |
vscode-azureresourcegroups | ms-azuretools | 0.4.0 |
vscode-commons | redhat | 0.0.6 |
vscode-css-formatter | aeschli | 1.0.1 |
vscode-dotnet-auto-attach | DennisMaxJung | 1.1.1 |
vscode-dotnet-runtime | ms-dotnettools | 1.3.0 |
vscode-eslint | dbaeumer | 2.2.1 |
vscode-html-css | ecmel | 1.10.2 |
vscode-java-debug | vscjava | 0.36.0 |
vscode-java-dependency | vscjava | 0.18.8 |
vscode-java-pack | vscjava | 0.18.5 |
vscode-java-test | vscjava | 0.32.0 |
vscode-maven | vscjava | 0.34.0 |
vscode-nuget-gallery | patcx | 0.0.24 |
vscode-peacock | johnpapa | 3.10.1 |
vscode-proto3 | zxh404 | 0.5.4 |
vscode-pylance | ms-python | 2021.10.0 |
vscode-remote-extensionpack | ms-vscode-remote | 0.21.0 |
vscode-xml | redhat | 0.18.0 |
vscodeintellicode | VisualStudioExptTeam | 1.2.14 |
vsliveshare | ms-vsliveshare | 1.0.4991 |
vsliveshare-audio | ms-vsliveshare | 0.1.91 |
vsliveshare-pack | ms-vsliveshare | 0.4.0 |
wav-preview | sukumo28 | 1.8.0 |
Issue Analytics
- State:
- Created 2 years ago
- Reactions:14
- Comments:11 (2 by maintainers)
Top GitHub Comments
I’ve created a fairly crude extension which works for now. dotnet watch attach.
Would however still like to see this actually implemented 😃
@Skrypt @MarcoMedrano @loligans
The issues you have mentioned have since been solved for my plugin dotnet watch attach
I specifically tested Ubuntu 22.04 and development in WSL from windows (should be similar to the development container)
Another developer contributed support for the M1 Macs.
If you encounter any issues, please let me know by creating an issue in this repository