This article will be the first of a serie about .NET Core and raspberry pi.
The first one will be about how to install .NET Core on the raspberry and test its validity.
Install raspberry part
First of all you will need to install some packages running the following command line:
sudo apt-get install libunwind8 libunwind8-dev gettext libicu-dev liblttn g-ust-dev libcurl4-openssl-dev libssl-dev uuid-dev
In order to download and install the latest version available of .NET Core, youw should visit this page, you will find here the version you need.
Then when you have the url of the version you want, you can go to your raspberry in order to download and install it.
Then run the following command (exemple):
sudo wget https://dotnetcli.blob.core.windows.net/dotnet/Runtime/master/dotnet-runtime-latest-linux-arm.tar.gz
This will download the file and put it on the folder where you are currently. Once you have download the archive, you will need to « unzip » it with the following command:
sudo tar -xvf dotnet-runtime-latest-linux-arm.tar.gz -C /home/raspbian/dotnet
As you can see, the content of the archive will be extract to the folder
One thing I usually do is to create a shorcut for the command, in this way, I will be able to run dotnet in every folder.
To do so, you have to run this:
sudo echo "PATH=\$PATH:home/raspbian/dotnet" >> dotnetcore.sh
This will create a sh file
Then move the file to profile.d
sudo mv dotnetcore.sh /etc/profile.d
Then reboot your device, the installation should be complete now!
Intall windows part
For windows it’s much more simple, I will just need to install the SDK, to find it just go to this page download the MSI and then run it.
I also recommend you to install VS Code, which will be usefull to work with .NET Core.
Create a hello world
What’s left now is to create a simple hello world console application and run it on the raspberry!
On your Windows computer, using Powershell run the following command:
dotnet new console
This will create a really simple project:
In this project you will find a csproj file, if you open it, its quite simple:
It just define the target framework of your project.
However in my case there is a difference of version between the SDK on my Windows and the runtime on my Raspberry. In order to align both, I will make a small modification to the csproj:
We are almost done, just tow more command line with Powershell
Now you have an application build and ready to run.
Just copy the content of the « bin/debug » to your raspberry using Winscp for exemple, once you copy it, go back to your Pi and go to the folder you just copy and run:
That’s all, you are now able to install .NET Core and run a simple application on raspberry pi.