How to Deploy .NET Core 2 on Raspberry Pi 3B

There is very little information on how to deploy .NET Core 2 on Linux ARM processors. I found a few articles online, but they were not detailed enough, and I hit a wall following their tutorials. After several days of struggle, I finally succeeded in the deployment. Here is a successful run screenshot:

How to Deploy .NET Core 2 on Raspberry Pi 3B

1. In the Windows system, run the CMD command in the project directory to publish:

dotnet publish -r linux-arm

Note: -r indicates the target runtime, which can be win-arm, linux-arm, win-x86, win-x64, etc.

How to Deploy .NET Core 2 on Raspberry Pi 3B

2. In the project directory, a bin\Debug\netcoreapp2.0\linux-arm folder will be generated. Copy all the contents of the publish folder under the linux-arm folder to the Raspberry Pi.

How to Deploy .NET Core 2 on Raspberry Pi 3B

3. Log in to the Raspberry Pi, enter the directory of the copied files, and grant the copied project permissions 755 or 777.

#>chmod 777 ./StudyTwo

How to Deploy .NET Core 2 on Raspberry Pi 3B

Then execute:

#>./StudyTwo

, at this point, if the environment is not set up correctly, it will definitely throw an error.

How to Deploy .NET Core 2 on Raspberry Pi 3B

4. Next, configure the .NET Core 2 runtime environment on the Raspberry Pi:

4.1 Update the system:

#> sudo apt update && sudo apt upgrade

4.2 Install dependencies:

#>sudo apt install curl libunwind8 gettext

4.3 Download the latest version of the armhf version of the .NET runtime. The latest version can be found at: https://github.com/dotnet/core-setup

#>wget https://dotnetcli.blob.core.windows.net/dotnet/Runtime/master/dotnet-runtime-latest-linux-arm.tar.gz

How to Deploy .NET Core 2 on Raspberry Pi 3B

4.4 Create a dotnet folder in the /opt directory and extract the runtime files to this folder:

#>sudo mkdir -p /opt/dotnet && sudo tar zxf dotnet-runtime-latest-linux-arm.tar.gz -C /opt/dotnet

4.5 Create a shortcut to the local bin:

#> sudo ln -s /opt/dotnet/dotnet /usr/local/bin

5. Finally, return to the .NET project directory and run:

#>./StudyTwo

The result will display, success.

How to Deploy .NET Core 2 on Raspberry Pi 3B

Original article link: http://www.cnblogs.com/fireicesion/p/8460355.html

.NET community news, in-depth articles, welcome to visit the public account article summary http://www.csharpkit.com

Leave a Comment

×