Easy guide to running .NET Core 2.0 applications on Raspberry Pi 2 and 3 with Raspbian Stretch.
It is possible to run (but not build) .NET Core 2.0 applications on Raspberry Pi 2 and 3 with Raspbian. This means the SDK cannot be installed onto Pi. This is perfectly fine for me as I build on my Ubuntu laptop and publish it for Linux ARM.
In my setup, I am using Raspbian Stretch Lite because I do not need desktop environment. This guide should work for the full variant nonetheless.
As at 10 March 2018, Microsoft does not list Raspbian as a supported distribution on its documentation. However, the dependencies listed for Ubuntu 17.x is almost the same.
sudo apt-get update sudo apt-get install libunwind8 liblttng-ust0 libcurl3 libssl1.0.2 libuuid1 libkrb5-3 zlib1g libicu57
The only thing that is different is swapping out
The version to use is .NET Core 2.0 SDK.
Create a new folder and name it whatever you like. Then change directory into it using command line:
dotnet new web
This should also perform
dotnet restore implicitly.
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.
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.
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.
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 &
Do NOT run the exe/dll file. Run the extensionless binary.
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.