Running .NET Core 6.0 Applications and Websites on Raspberry Pi 4B
Environment Setup
Install .NET Core Dependencies
sudo apt install -y libunwind8 libunwind8-dev gettext libicu-dev liblttng-ust-dev libcurl4 libcurl4-openssl-dev libssl-dev uuid-dev unzip libgdiplus libc6-dev libkrb5-3
Download and Unzip the .NET SDK
wget https://download.visualstudio.microsoft.com/download/pr/1f85b038-9917-4d0a-8485-5dc86510eec7/a7555924fe292c6c2140893f066abe65/dotnet-sdk-6.0.100-linux-arm.tar.gz -O dotnet-sdk-linux-arm.tar.gz --no-check-certificate
sudo mkdir -p /usr/local/dotnet && sudo tar zxf dotnet-sdk-linux-arm.tar.gz -C /usr/local/dotnet
Create a Symbolic Link
sudo ln -s -f /usr/local/dotnet/dotnet /usr/local/bin
P.S. A symbolic link (also called a symlink or soft link) is a type of link file similar to a Windows shortcut. /usr/local is typically where executable programs are placed. Basically, all of Linux's built-in executables are located here.
Test dotnet
dotnet --version

Part 1: Running a .NET Core Console Application on Raspberry Pi
Create a new .NET Core console application project


Right-click the project, then Publish > Folder > Finish > Publish

Xftp is a tool that uses the SSH protocol to quickly upload files to Linux through a UI. To copy your locally built .NET Core application to the Raspberry Pi, you can easily do it with Xftp.
Switch to the newly uploaded .NET Core folder
cd NetCoreTest/
Run dotnet ConsoleApp1.dll

Part 2: Running a .NET Core Website on Raspberry Pi and Registering It as a Service to Start on Boot
Follow the same steps as for the .NET Core console application to copy the build output of your .NET Core web application to the Raspberry Pi using Xftp.



Right-click the project, then Publish > Folder > Finish > Publish

Switch to the uploaded folder and specify the URL and port number
dotnet LetGo.Label.Service.dll --urls "http://localhost:5100;https://localhost:5101"
Finally, visit the URL

If you want the application to start automatically on boot, you can register it as a service.
sudo vim /lib/systemd/system/label.service
[Unit]
Description=Label Services
After=network.target
Wants=network.target
[Service]
Restart=on-failure
RestartSec=5
ExecStart=dotnet /var/label/LabelService.dll --urls "http://localhost:5100;https://localhost:5101"
[Install]
WantedBy=multi-user.target
Start the label service you just registered
sudo systemctl start label.service //啟動 FRP Server 服務
sudo systemctl stop label.service //停止 FRP Server 服務
sudo systemctl restart label.service //重啟 FRP Server 服務
sudo systemctl enable label.service //開機時自動啟動 FRP Server 服務
sudo systemctl disable label.service //開機時不要啟動 FRP Server 服務
sudo systemctl status label.service //查看FRP Server 狀態
sudo systemctl is-failed label.service // 查看失敗狀態
sudo systemctl daemon-reload // reload service
sudo systemctl status frpc.service





























Comments