Installing .Netcore on a Raspberry Pi 3

I wanted to use my Raspberry Pi 3 to host a .Netcore WebApi as now Microsoft turned their framework open-source. But my journey to a .netcore Pi was not as straightforward as what I first thought… So here is a small “how to” that you can use if you want to achieve the same in less time.

“raspberries” by Jametlene Reskp on Unsplash

Install Raspbian

This step is pretty easy and that’s why I will lead you directly to the official documentation which contains everything you would need to install you PI https://www.raspberrypi.org/downloads/raspbian/

Install .netcore

First, we’ll need to find the build of dotnet core we want to install. You’ll find on the following github page a table of release and OS : https://github.com/dotnet/core-setup#daily-builds

Choose the one you need, and copy the link of the tar.gz release for the next step.

Hint : The Raspberry Pi 3 was built with a x64 processor but still has a 32bit architecture. You’ll then want to use the “Linux (armhf)(for glibc based OS)” version of the package.

For the Raspberry Pi 3, the one to use is the following: https://dotnetcli.blob.core.windows.net/dotnet/Runtime/release/2.1/dotnet-runtime-latest-linux-arm.tar.gz

Now that we have the package, we’ll need to download it. Open you terminal and fetch the package via curl with this single command :

curl -sSL -o dotnet.tar.gz https://dotnetcli.blob.core.windows.net/dotnet/Runtime/release/2.1/dotnet-runtime-latest-linux-arm.tar.gz

Now we need to create the destination folder where you will copy the dotnet runtime :

sudo mkdir -p /opt/dotnet

The previously downloaded package should now be extracted to this new folder:

sudo tar zxf dotnet.tar.gz -C /opt/dotnet

Nice, we have now the dotnet runtime on our Pi. But as you may have noticed, we still don’t have any dotnet cmd recognized by the system. What is missing is a link to the dotnet cli in the local/bin folder to be able to access it from every folder:

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

Now you should be able to run a simple command to test the installed runtime :

dotnet --help

If you get an error there, it’s probably because you choosed a wrong architecture. In that case, delete the /opt/dotnet folder, and start again this chapter.

Note: As we’ve installed the runtime and not the sdk, you’ll only have access to some commands and not to all the development features like : dotnet new|restore|build|...

As of today the development tools are not available yet and will need to develop and build on you Windows|MacOS machine, and then install the builded application on your Pi.

Now you have dotnetcore on your Pi. If you want to run console application, go on. But if you wan’t to expose a WebApi, you’ll need some other stuff. This will be covered in a next article.

Thanks for reading