Debugging Dot Net Core applications on a Raspberry Pi with Visual Studio

Debugging Dot Net Core applications on a Raspberry Pi with Visual Studio

I have a great post here that details how to install the Visual Studio debugger on a Raspberry Pi. That, together with the Dot Net Core libraries, gives you everything you need to remote debug code running on the Pi, but how do you attach it to the Pi from Visual Studio?

You connect using the normal ‘Attach to Process’ option in the Debug menu.

image-81 Debugging Dot Net Core applications on a Raspberry Pi with Visual Studio

There are several options in the connection type drop-down. With the Raspberry Pi, you select SSH. I wasn’t aware that you could debug over SSH, but it is cool that you can!

image-80 Debugging Dot Net Core applications on a Raspberry Pi with Visual Studio

Having selected SSH, you change the Connection Target to the credentials you want to use to connect to the Pi. As I typically create just one account for admin on the Pi, I enter admin@ipaddress.

After a few seconds, Visual Studio connects to the Pi and lists the running processes; you select the process you want to connect to and click the Attach button at the bottom of the screen, and it connects.

It works in exactly the same way you debug local applications. You can set breakpoints, view/amend variables, run commands in the Immediate window, and do everything else you usually do.

Stephen

Hi, my name is Stephen Finchett. I have been a software engineer for over 30 years and worked on complex, business critical, multi-user systems for all of my career. For the last 15 years, I have been concentrating on web based solutions using the Microsoft Stack including ASP.Net, C#, TypeScript, SQL Server and running everything at scale within Kubernetes.