The VS Linux Debugger is an open-source tool created to assist with remotely deploying and debugging your Linux applications from Visual Studio 2022. Check it out on the Microsoft Marketplace or GitHub.
To get started using it today it’s as easy as 1-2-3.. or perhaps, 2-3
Before getting started, it is recommended to ensure your system has the latest updates. These steps have been tested against Ubuntu 20.04 LTE and 22.04 LTE.
Though this project supports everywhere that .NET (Core) is supported, this section outlines steps for Ubuntu 22.04 LTE. It’s recommended to use the official Microsoft Install .NET on Linux guide.
If this is a new Ubuntu VM on Virtual Box, don’t forget to install the extensions
$ sudo apt install virtualbox-ext-pack
Before getting started, make sure your system has the latest updates.
On your Linux machine install OpenSSH Server and cURL.
sudo apt update sudo apt install openssh-server sudo apt install curl
Now test your connection on Windows
Install .NET 6
Run the following commands to add the Microsoft package signing key to your list of trusted keys.
wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb sudo dpkg -i packages-microsoft-prod.deb rm packages-microsoft-prod.deb
Next, install the SDK
sudo apt-get update; \ sudo apt-get install -y apt-transport-https && \ sudo apt-get update && \ sudo apt-get install -y dotnet-sdk-6.0
For other .NET versions reference the table below
Install the Extension
- Open Visual Studio
- Extensions > Manage Extensions
- Search for “VS Linux Debugger”
- Install and restart Visual Studio
Configure and Deploy
First, we’ll need to get the IP Address of the remote machine
Open a terminal and type,
ifconfig, and copy the IP Address. In this example,
192.168.1.227. Please note, if you’re using a NAT connection on a VM it may appear as,
127.0.0.1. NAT and Bridged connections will be covered at a later time.
Next, we’re going to configure the Linux Debugger extension
- Visual Studio > Tools > Options
- Select, “Linux Debugger” from the treeview
- Input the IP Address
- Input the User Name
- Input the Password
- Click, OK
Deploy and Debug
Now you’re ready to deploy and debug your applications! We’ll begin by making a new .NET 6 Console application.
Console.WriteLine("Hello .NET 6, VS Linux Debugger!"); Console.WriteLine("Apply breakpoint here!"); Console.WriteLine("All done!");
After setting your breakpoint in the sample, you can now Deploy and Debug!
- Visual Studio > Extensions > Linux Debugger
- Select, Build, Deploy and Debug.
To debug Linux GUI applications debugging, I’m currently working on a solution for that. For now, you can still use Build and Deploy followed by manually attaching to the process in Visual Studio to debug it.
- VS: Linux Debugger > Build and Deploy
- Run the app on the remote machine via, “dotnet MyApp.dll“
- VS: Debug > “Attach to Process…“
- Connection Type to, SSH
- Connection Target: “UserName@IPADDRESS”
Bonus: Output Window
You can monitor and debug the commands sent to your remote device via the Output window’s Linux Debugger output