Skip to content

Debugging Manually

Damian edited this page Oct 15, 2022 · 4 revisions

Manual Debugging

In most cases, you should be able to automatically debug via Build, Deploy and Debug. However, some Linux distros or configurations can be troublesome, causing some developers to do a semi-manual debugging process.

To debug Linux GUI applications debugging, a solution is currently in progress. For now, you'll have to use this semi-automated process.

Console Apps Only

In the app's Main() add, Console.ReadLine() at the beginning.

This will allow your app to start up and wait for you to Attach to Process as seen in the next section below.

PRO TIP: For professional/enterprise applications, you may want to surround this with a compiler switch like, #if DEBUG, to ensure this doesn't go into your software Releases

public static void Main(string[] args)
{
  #if DEBUG
  Console.ReadLine();
  #endif

  // Set breakpoint here for testing
  Console.WriteLine("Welcome to, VS Linux Debugger!");
  // .. Remaining app code below
}

GUI and Console Steps

  1. Set your desired breakpoints
  2. (VS) Linux Debugger > Build and Deploy
  3. Run the app on the remote machine via, dotnet MyApp.dll
  4. (VS) Debug > "Attach to Process..."
  5. Select Connection Type, SSH
  6. Set the Connection Target: "UserName@IPADDRESS". Press, <enter>
    • Input user credentials. Click, Connect
    • If prompted with Accept Host Key, click, Yes
  7. Select your Process and click, Attach
    • Process is dotnet, and Title will be the command you typed.
  8. Check, Managed (.NET Core for Unix)
  9. Click, OK

Next Visual Studio will briefly show a pop-up stating, "Launching debugger adapter...". This may take a moment.

Enjoy debugging!

Firewall

Ensure that you have the appropriate Firewall access to your remote machine via SSH.

To assist, in the Attach to Process dialog:

  • After inputting your Connection Target details, click, Find
  • If prompted, accept the Window Defender Firewall prompt, clicking appropriate boxes (both Private and Public if applicable)
Clone this wiki locally