Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

debug a dotnet core program in terminal

I’ve recently setup omnisharp with nvim and wanted to try to develope a dotnet core application without the help of VS/rider/vs code.

Now i tried to google around but couldn’t find any real way to debug dotnet core applications from terminal.

What’s the correct way to debug one?

like image 501
Lyze Avatar asked Jun 29 '18 18:06

Lyze


People also ask

How do I Debug a .NET core console application?

Open the Debug view by selecting the Debugging icon on the left side menu. Select the green arrow at the top of the pane, next to . NET Core Launch (console). Other ways to start the program in debugging mode are by pressing F5 or choosing Run > Start Debugging from the menu.

How do I Debug a Dot Net command?

You can do this by clicking on the arrow next to Run button in Visual Studio and selecting 'Project Debug Properties'. From there, you can go to 'Application Arguments' and enter the arguments you want.

How do I Debug .NET core source?

To debug . NET and ASP.NET Core source code in Visual Studio: In Tools -> Options -> Debugging -> General, un-check Enable Just My Code. Verify Enable Source Link support is checked.


1 Answers

Unfortunately, this is going to be a very painful experience. There's no real command line debugger available for .NET Core.

However, CoreCLR developers use a plugin for lldb (on *nix) that teaches lldb about a number of commands that it can use to help debug .NET code.

Essentially:

lldb /path/to/dotnet/dotnet
plugin load /path/to/dotnet/shared/Microsoft.NETCore.App/*/libsosplugin.so
b SystemNative_ReceiveMessage
r run
clrstack

Further documentation:

  • A tutorial: https://blogs.msdn.microsoft.com/premier_developer/2017/05/02/debugging-net-core-with-sos-everywhere/
  • General setup instructions: https://github.com/dotnet/coreclr/blob/master/Documentation/building/debugging-instructions.md
  • List of commands: https://github.com/dotnet/coreclr/blob/master/src/ToolBox/SOS/Strike/sosdocsunix.txt

If you start using it, you will quickly realize how painful this is. It's almost worth using VS/Rider/VSCode just for the debugger, sadly.

like image 88
omajid Avatar answered Oct 13 '22 01:10

omajid