- VS Code installed on your PC or laptop
- Operating system is installed on your Raspberry (https://www.raspberrypi.com/software/) You can also use RPI-imager to install system by command “sudo apt install rpi-imager”
- Your PC or laptop and your Raspberry Pi are connected to same WI-FI network
Setting up your SSH connection (Passwordless)( https://danidudas.medium.com/how-to-connect-to-raspberry-pi-via-ssh-without-password-using-ssh-keys-3abd782688a)
- You need to know your Raspberry IP address. If it is connected you can find it while hovering WIFI icon in top right corner. You can also use command “hostname -I” in Raspberry terminal.
-
Enable SSH server in raspberry Run command “sudo raspi-config” select “Interface Options” and enable access using SSH
-
Enable SSH server in Windows Open “Settings” > “Apps” > “Apps & Features” > “Optional Features. Select “Add Features” and “OpenSSH Server” and “Install” (admin rights required). Set the startup type for “OpenSSH Authentication Agent” and “OpenSSH Server” to “Automatic” in the Windows “Services” app.
-
Now you should be able to connect via windows CMD to your raspberry Use command in windows cmd “ssh userName@IP”. You’ll be asked for password.
-
Generate an ssh key pair (private-public) on your local computer First, check if you already have one. Default all the ssh keys are located in ~/.ssh folder on your computer. If you don’t have this folder or it’s empty you don’t have. To generate a new rsa key pair go to Terminal and simply type and follow the steps ssh-keygen ~/.ssh/id_rsa — This is your private key. NEVER share this file with anybody and DO NOT copy this file to external computers/servers. ~/.ssh/id_rsa.pub — This is the public key. The content of this file can be shared and the content of this file we will need to copy to the raspberry pi.
-
Run command "ssh-keygen" on Raspberry Pi, leave empty, press ENTER Now look inside your .ssh directory: “ls ~/.ssh” and you should see the files id_rsa and id_rsa.pub: authorized_keys id_rsa id_rsa.pub known_hosts
-
Copy public key to Raspberry Pi vim ~/.ssh/authorized_keys // paste in this the content of the ~/.ssh/id_rsa.pub from your local computer
Or open file manually and paste content from your local PC .pub file
run command “ssh-copy-id USERNAME@IP-ADDRESS”
You'll be asked for a password
Now try to connect once again from your local PC via SSH, connection should be passwordless
Install DOTNET on Raspberry device (https://learn.microsoft.com/en-us/dotnet/iot/deployment)
-
Run command curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --channel STS
-
Add .NET as a path by commands:
echo 'export DOTNET_ROOT=$HOME/.dotnet' >> ~/.bashrc
echo 'export PATH=$PATH:$HOME/.dotnet' >> ~/.bashrc
source ~/.bashrc
- Verify .NET installation by command “dotnet --version”
Run command “mkdir NetRasp“ that will create folder in your RaspBerry folder: /home/woselko/NetRasp Run command “dotnet new console -n NetRaspApp” that will create a console app
Install VS Remote Debugger(https://learn.microsoft.com/en-us/dotnet/iot/debugging?tabs=self-contained&pivots=vscode)
- Run command “curl -sSL https://aka.ms/getvsdbgsh | /bin/sh /dev/stdin -v latest -l ~/vsdbg”
Install below extensions to help ssh connection via vs code
Type in vs code Ctrl+Shift+P to open Command Pallete and run below command
+Add New Connection Host and type your Raspberry creds @
And Connect Select Open Folder
Open your main app folder
After Successful opening you’ll be asked for adding .net vs code assets, it will be very helpful during build, publish and deploy app.
Check .vscode/tasks.json to see how build, publish, deploy task is performed, you can you use those patters Check .vscode/launch.json to see how launch and debugger is attached REMEMBER to change your credentials and check paths After all you should be able to run your app and breakpoints should be hitted.
After successful RUN, application should be build, published and deployed to below location