I have a C# .NET CORE console application running in a Docker container, which runs in WSL2 Ubuntu 20.04.
Now I would like to use Visual Studio (in Windows) to debug that C# console app running in that Docker container.
How can I do it in Visual Studio?
I have tried using the method suggested in here, but unsuccessful when I tried to connect to Remote System
Can anyone point me how to debug C# code by attaching to a process running in a Docker container hosted in WSL2?
2
Answers
2.1 Connection type: Windows Subsystem for Linux (WSL)
2.2 Connection target: your distro name
2.3 Attach to: Managed (.NET Core for Unix) code
The attach to process dialog now supports connecting to a process in a container: https://learn.microsoft.com/en-us/visualstudio/debugger/attach-to-process-running-in-docker-container?view=vs-2022#attach-to-a-process-running-on-a-linux-docker-container
Also, when the container is running through the local Docker Desktop you can start the attach to a process dialog from the Containers window in VS: https://learn.microsoft.com/en-us/visualstudio/containers/view-and-diagnose-containers?view=vs-2022#attach-the-debugger-to-a-process