-
Notifications
You must be signed in to change notification settings - Fork 10
Debugging Manually
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.
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 Releasespublic 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 }
- Set your desired breakpoints
- (VS) Linux Debugger > Build and Deploy
- Run the app on the remote machine via,
dotnet MyApp.dll
- (VS) Debug > "Attach to Process..."
- Select Connection Type, SSH
- Set the Connection Target: "UserName@IPADDRESS". Press,
<enter>
- Input user credentials. Click, Connect
- If prompted with Accept Host Key, click, Yes
- Select your Process and click, Attach
- Process is dotnet, and Title will be the command you typed.
- Check, Managed (.NET Core for Unix)
- Click, OK
Next Visual Studio will briefly show a pop-up stating, "Launching debugger adapter...". This may take a moment.
Enjoy debugging!
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)
Copyright 2023 Xeno Innovations, Inc.