Running .NET Core on Raspberry Pi Raspbian
Easy guide to running .NET Core 2.0 applications on Raspberry Pi 2 and 3 with Raspbian.
Tested on 16 July 2017. It is possible to run (but not build) .NET Core 2.0 applications on Raspberry Pi 2 and 3 with Raspbian. This is perfectly fine for me as I build on my Windows laptop and publish it for Linux ARM.
Install pre-requisites on RPi
Run the following to install runtime dependencies:
sudo apt-get update sudo apt-get install libc6 libcurl3 libgcc1 libgssapi-krb5-2 libicu52 liblttng-ust0 libssl1.0.0 libstdc++6 libunwind8 libuuid1 zlib1g
Install pre-requisites on Windows
At time of writing, the version to use is .NET Core 2.0 SDK Preview 2.
Build and test Hello World ASP.NET Core
Create a new folder and name it whatever you like. Then change directory into it using command line:
dotnet new web
Take a look at the
.csproj file. It should contain:
If the value is not
netcoreapp2.0, something went wrong while installing .NET Core 2.0 SDK.
Next, restore dependencies using the following command:
Verify that the application works by running:
You should be seeing:
Now listening on: http://localhost:5000 Application started. Press Ctrl+C to shut down.
Publish application for Linux ARM
To be able to run this application on RPi, it is necessary to publish the application for that specific environment.
dotnet publish -r linux-arm
The published output appears under
Copy the entire
linux-arm folder contents to RPi. My preference is SFTP.
Run the application on RPi
From here on, perform the steps below on Raspberry Pi.
Grant the HelloWorld binary execute permissions or else you cannot run it:
chmod 755 HelloWorld
Then run the application in the background without outputting to console:
./HelloWorld > /dev/null &
You should be seeing output like below where the xxxxx is the Process ID (PID):
Give it a few seconds to startup.
Perform a simple HTTP test using:
If you see Hello World!, congratulations. You have successfully completed this super simple tutorial.