Using Visual Studio 2022 to develop, deploy and debug on Raspberry PI

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:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code># 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
</code>
<code># 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 </code>
# 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:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code><PropertyGroup>
<RuntimeIdentifier>linux-arm</RuntimeIdentifier>
<PublishTrimmed>true</PublishTrimmed>
</PropertyGroup>
</code>
<code><PropertyGroup> <RuntimeIdentifier>linux-arm</RuntimeIdentifier> <PublishTrimmed>true</PublishTrimmed> </PropertyGroup> </code>
<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:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>scp -r ./bin/Debug/net8.0/linux-arm/* admin@devpi:/home/admin/ConsoleApp1
</code>
<code>scp -r ./bin/Debug/net8.0/linux-arm/* admin@devpi:/home/admin/ConsoleApp1 </code>
scp -r ./bin/Debug/net8.0/linux-arm/* admin@devpi:/home/admin/ConsoleApp1

Finally, the launch.json file in my project is as follows:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>{
"profiles": {
"ConsoleApp1": {
"commandName": "Project",
"workingDirectory": "/home/admin/ConsoleApp1",
"remoteDebugEnabled": true,
"remoteDebugMachine": "devpi:22",
"authenticationMode": "None"
}
}
}
</code>
<code>{ "profiles": { "ConsoleApp1": { "commandName": "Project", "workingDirectory": "/home/admin/ConsoleApp1", "remoteDebugEnabled": true, "remoteDebugMachine": "devpi:22", "authenticationMode": "None" } } } </code>
{
  "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?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật