SLP
SLP

Reputation: 311

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 ?

Upvotes: 4

Views: 4020

Answers (2)

Alexei - check Codidact
Alexei - check Codidact

Reputation: 23108

I had the same issue after upgrading a ASP.NET Core 2.2 project to ASP.NET Core 3.0. I have used a trick to find out the process I should attach to whenever needed:

  • Run with Debug (F5)
  • Attach to Process
  • Find the process which is grayed out (already attached). This is the process that should be used to further process attachments

In my case the process was called {AssemblyName}.exe.

Side note: You can find Reattach extension particularly useful for quickly reattaching (e.g. Ctrl-R Ctrl-1) to previous processes.

Upvotes: 6

SLP
SLP

Reputation: 311

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

Upvotes: 2

Related Questions