Debug Multiple Microservices in Visual Studio

2.7k Views Asked by At

I have a solution which contains two microservices and an API gateway. While debugging, the solution requires to run again and again to get insights or fix bugs.

I have tried dotnet watch run but with this I can attach debugger to one project at a time. Hosting applications on IIS also requires to copy the files to folder every time for small changes as compared to in .NET Framework where it was easier to host applications on localhost and attach to process.

Currently, I have been debugging it using visual studio with multiple startup projects.

Since pressing F5 constantly is repetitive and hectic so is there any other way around to debug multiple projects using dotnet watch or IIS or anything else?

2

There are 2 best solutions below

0
On

ctrl+F5 can run multiple, but it will not debug. Other solution try run multiple VS studio, but I'm not sure

0
On

There is possibly another way. I was also had issues running multiple projects to debug microservices.

I explored a few possibilities:

  • Docker - didn't help and ate more memory (if our whole stack was .net core this might be the goto)
  • Auto starting VS projects with a script (better but not quiet the level of control we needed)
  • Researched all the things that people said (use logging, do tests etc, all of which ignore the fact that we don't all have perfect codebases to work in)

Finally I created something that works well for our team, and maybe it'd work for you? Dev Launcher is a simple command line utility that you configure with your project information. It's currently aimed at handling .net full framework, runs in (Visual Studio) and .net core runs with (Visual Studio or dotnet run). It is configurable and I'm guessing a person could get it to work with other IDE's such as VS Code, though I haven't tried it.

The main concept is you first choose the projects you'd like to open for debugging. These projects will open in the IDE which is configured (Defaults to Visual Studio). Then you choose the supporting microservices that you'd like to run in the background. If these are written in .net core they will run in a console window, freeing the memory that would normally be consumed by the IDE and debugger.

Curious to see if that'd be helpful for your situation. Also curious what other ideas people have to make debugging multiple microservices better...