Skip to content

Latest commit

 

History

History
134 lines (92 loc) · 5.43 KB

readme.md

File metadata and controls

134 lines (92 loc) · 5.43 KB

Remotely deploy and debug your .NET C# apps via SSH to Linux using Visual Studio 2022.

Get it on the VS MarketPlace!

Visual Studio's "attach to process via SSH" is cute, but it lacks deployment and automatic attaching. This project allows you to do just that on your Linux VM or Raspberry Pi over the network!

Suess Labs consulting is sponsored by Xeno Innovations, Inc.

Overview

Now developers can build, deploy and debug projects on their remote Linux (Ubuntu, Raspberry PI, etc) devices! Customize your SSH connection to use either a password or a private key.

If you enjoy using the extension, please give it a ★★★★★ rating on the Visual Studio Marketplace.

Supported Remote OS

The following Linux distrobutions have been validated and are supported.

  • Ubuntu (20.04 LTS, 22.04 LTS)
  • Raspberry PI OS

Usage

VS Menu

  • Build and upload to remote devices
  • Remote debugging*
    • This is still in the experimental stages. Please use VS' Attach to Process if you have issues
  • VS Linux Debugger will automatically detect and install vsdbg for you!

For GUI app debugging, you can use the Build and Deploy feature, however, you must manually Attach to Process via SSH using Visual Studio at this time.

Getting Started

Linux, we'll need SSH and cURL for access and downloading any missing tools:

sudo apt install openssh-server
sudo apt install curl

Windows:

  1. Open Visual Studio (VS) > Tools > Options > Linux Debugger
  2. Input: Remote Host IP address
  3. Input: Remote's User Name and Password
  4. VS > Extensions > Linux Debugger > Build, Deploy, Debug

Tools Options

Manually Attaching (for GUI apps)

For GUI projects, you can use Build and Deploy and then manually attach to the process via SSH by using Visual Studio's built-in tool

  1. Deploy to remote machine via
    1. Extensions > Linux Debugger > "Build and Deploy"
  2. Run GUI app on remote machine
    1. dotnet MyGuiApp.dll
  3. Debug > "Attach to Process.."
  4. Connection Type: SSH
  5. Connection Target: (Remote machine's IP)
  6. (Select process)
  7. Click, Attach
  8. Check, "Managed (.NET Core for Unix)"
  9. Click, OK

This will save you 1.5 minutes on every build of manual uploading and updating rights via chown -R.

Manually Attaching (for Command line apps)

For CLI projects, you can use Build and Deploy and then manually attach to the process via SSH by using Visual Studio's built-in tool (similar to above).

You may have to manually interrupt your app via Console.ReadLine(); high-up in your entry-point (i.e. main()).

  1. Deploy to remote machine via
    1. Extensions > Linux Debugger > "Build and Deploy"
  2. Run your CLI app on remote machine
    1. dotnet MyCliApp.dll
  3. Debug > "Attach to Process.."
    1. Connection Type: SSH
    2. Connection Target: (Remote machine's IP)
    3. (Select process)
    4. Click, Attach
    5. Check, "Managed (.NET Core for Unix)"
    6. Click, OK
  4. Continue your application, if using a manual interrupt (i.e. Console.ReadLine();)

This will save you 1.5 minutes on every build of manual uploading and updating rights via chown -R.

How To Generate Private Key (optional)

The following steps are options if you wish to use an SSH Private Key. These steps were written for Windows 10, however, on Linux the steps are similar.

  1. Open PowerShell:
  2. Generate key (with old PEM format)
    1. ssh-keygen -m PEM -t rsa -b 4096
    2. In the future, we'll be able to use ssh-keygen.. just not yet.
  3. Set output name (default is okay for basic setups)
  4. Input a passphrase for the key (OPTIONAL)
  5. Windows will now generate your RSA public/private key pair.
    1. Default location: %UserProfile%\.ssh (WINOWS)
    2. The public key will be stored as id_rsa.pub in the directory
  6. Upload the public key to your remote machine
    1. Navigate to folder, ~/.ssh/ on Linux device
    2. If ~/.ssh/authorized_keys exists, append the contents of id_rsa.pub to the next line.
    3. If it does not exist, simply upload id_rsa.pub and rename it to, authorized_keys
  7. DONE!

Future Features

  • Debugging: Launching of GUI apps for remote debugging
  • Debugging: PLink using PPK instead of manual password
  • Options Window: Multiple remote profile management
  • Options Window: SSH PPK generator assistant tool

Developers Wanted

Contributors and Q/A are welcomed!

To contribute, please pick off an item from the project or issue page. We'd love to hear your enhancement ideas as well.

References

Copyright 2024 Xeno Innovations, Inc.