{"id":2576,"date":"2021-01-31T09:21:08","date_gmt":"2021-01-31T09:21:08","guid":{"rendered":"https:\/\/wordpress-634681-2064240.cloudwaysapps.com\/?p=2576"},"modified":"2023-01-23T09:39:19","modified_gmt":"2023-01-23T09:39:19","slug":"deploying-and-debugging-raspberry-pi-net-applications-using-vs-code","status":"publish","type":"post","link":"https:\/\/www.petecodes.co.uk\/deploying-and-debugging-raspberry-pi-net-applications-using-vs-code\/","title":{"rendered":"Deploying and Debugging Raspberry Pi .NET Applications using VS Code"},"content":{"rendered":"\n

Historically, debugging embedded applications is hard. More often than not, you’ll be developing code on your desktop or laptop and deploying code to an embedded device.<\/p>\n\n\n\n

Getting everything set up to allow that to be seamless is often difficult to achieve.<\/p>\n\n\n\n

In this guide, I’ll show you how to configure your PC and a Raspberry Pi, to allow you to hit the F5 key in Visual Studio code and have the code shipped to the Raspberry Pi, run and have VS Code attach to the Visual Studio debugger actually on the Pi.<\/p>\n\n\n\n

There are alternatives to this methodology. One of them is the Remote SSH extension for VS Code<\/a>. However, this extension relies on the source code for your application to be stored on the device itself. I’m not a fan of this, as it means that you need to be consistently connected to the remote device to code. If you hop on a train and lose connectivity, you can’t save your work.<\/p>\n\n\n\n

This guide (and single line install script!) will configure your system so you can code entirely on your local machine with no reliance on the remote machine until you need to deploy.<\/p>\n\n\n\n

The previous version of this guide<\/h2>\n\n\n\n

This guide is actually a simplified version of a previous post<\/a> I made about remote debugging .NET Applications on a Raspberry Pi from VS Code.<\/p>\n\n\n\n

The previous version had relied on two different items; WSL with OpenSSH (primarily for rsync) and Putty’s Plink.<\/p>\n\n\n\n

This version uses the free cwrsync <\/a>tool to remove the need for WSL entirely. Further, using Scott Hansleman’s instructions here<\/a>, we can remove the need for plink entirely.<\/p>\n\n\n\n

Finally, I’ve created a one line script you can run from an elevated command prompt which makes getting your machine setup to Remote Deploy and Debug from Visual Studio Code a cinch!<\/p>\n\n\n\n

Prerequisites<\/h2>\n\n\n\n

Before you start, you’re going to need to have the following installed;<\/p>\n\n\n\n