I’m new to developing on the Raspberry Pi, and I’m trying to get setup so as I can build some headless console apps in Visual Studio 2022 with C# and .Net Core 8. I’ve been developing windows software in C# since forever and have always worked in Visual Studio – I’d prefer to carry on using that for this project, rather than have to get to grips with a new Dev tool like VS Code.
I’ve managed to get the Pi OS installed (32bit on a Pi 3B+), along with SSH using RSA keys, the .Net runtimes and debugger, using the following commands:
# Initial Update
sudo apt-get update
sudo apt-get full-upgrade
# Configure SSH RSA Key
mkdir -p ~/.ssh
chmod 700 ~/.ssh
echo "[Contents of %USERPROFILE%.sshid_rsa.pub on your PC]" >> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
exit
ssh admin@devpi
# DotNet 8 Runtime
wget https://dot.net/v1/dotnet-install.sh
chmod +x dotnet-install.sh
./dotnet-install.sh --channel 8.0
echo 'export DOTNET_ROOT=$HOME/.dotnet' >> ~/.bashrc
echo 'export PATH=$PATH:$HOME/.dotnet' >> ~/.bashrc
source ~/.bashrc
dotnet --info
# DotNet Debugger
curl -sSL https://aka.ms/getvsdbgsh | bash /dev/stdin -r linux-arm -v latest -l ~/vsdbg
dotnet --info
comes back with the expected results. So far, so good.
I’ve generated a simple little Hello World console app and am trying to find out how to deploy it to the Pi and remote debug it there whenever I hit F5. Unfortunately, after a couple of days of getting nowhere with Google, ChatGPT, YouTube, etc. I’m on the verge of throwing in the towel.
In my project file I’ve set it to build for a 32 bit linux environment as follows:
<PropertyGroup>
<RuntimeIdentifier>linux-arm</RuntimeIdentifier>
<PublishTrimmed>true</PublishTrimmed>
</PropertyGroup>
I’ve also got a post-build script setup to copy the binaries onto the Pi as follows:
scp -r ./bin/Debug/net8.0/linux-arm/* admin@devpi:/home/admin/ConsoleApp1
Finally, the launch.json file in my project is as follows:
{
"profiles": {
"ConsoleApp1": {
"commandName": "Project",
"workingDirectory": "/home/admin/ConsoleApp1",
"remoteDebugEnabled": true,
"remoteDebugMachine": "devpi:22",
"authenticationMode": "None"
}
}
}
Unfortunately, this is still looking for a folder on my local machine, rather than on the remote Raspberry Pi.
I’d prefer to avoid having to manually publish and deploy the software, then start the app on the pi and attach a remote debugger. Apart from being a pain in the backside, it doesn’t allow me to debug the startup code.
There must be a simpler way. Can anyone point me in the right direction?