Search code examples
asp.net-corevisual-studio-debuggingvisual-studio-2019

ASP.NET Core 3.0 - how to attach the Visual Studio debugger?


I have two Asp.Net Core projects - one is version 2.2. and one is version 3.0.

Each project is a brand new, empty MVC project created in Visual Studio.

I run each project by dropping to the command line and doing dotnet run.

I then debug my code as follows:

  1. Open Task Manager and find the process Id for the dotnet process
  2. Doing Debug -> Attach to Process in Visual Studio 2019

For the version 2.2 project, I can easily identify the correct dotnet process in Task Manager - it's the one showing the dotnet exec command pointing to my project's .dll file:

Task Manager for version 2.2

However - for the 3.0 project, the dotnet processes in Task Manager look like this:

enter image description here

None of the processes is clearly associated with my project's .dll files, and none of them allows me to debug my code using Attach to Process.

So my question is - is there a way of attaching Visual Studio's debugger to an Asp.Net Core 3.0 project when I run it using dotnet run ?


Solution

  • Turns out that the Asp.Net Core 3.0 project, when run using dotnet run, has a different entry in Task Manager than 2.2 - the .exe file produced by the build is what is displayed in Task Manager's details, and I can successfully attach to this process in Visual Studio:

    enter image description here