Setup .NET Core 2.1 on ARM

.NET Core supports ARM 32 architecture starting with version: 2.1.300, which is first official final release of .NET core 2.1.
This means, .NET developers can now target small devices like Raspberry PI. Note PI is supported from version 2+. Right now, support for GPIO is still not a part of .NET Core, but it is on the roadmap. For more information please take a look here.
However, you can start using GPIO as described here.

To start with .NET Core ARM version, you have to first install the SDK or runtime, dependng on what you want to do. I used Ubuntu MATE on my PI3. If you read this article on some later time, you will most likely have to change target version in scripts shown below. The best way to find a version is to go directly to GITHUB and peek the right one. I used 32bit SDK.

6100_core21

$sudo apt-get -y update
$ sudo apt-get -y install libunwind8 gettext
$ wget https://dotnetcli.blob.core.windows.net/dotnet/Sdk/2.1.300/dotnet-sdk-linux-arm.tar.gz
$ wget https://dotnetcli.blob.core.windows.net/dotnet/aspnetcore/Runtime/2.1.0/aspnetcore-runtime-2.1.0-linux-arm.tar.gz
$ sudo mkdir /opt/dotnet
$ sudo tar -xvf dotnet-sdk-2.1.300-linux-arm.tar.gz -C /opt/dotnet/
$ sudo tar -xvf aspnetcore-runtime-2.1.0-linux-arm.tar.gz -C /opt/dotnet/
$ sudo ln -s /opt/dotnet/dotnet /usr/local/bin

At the end execute folowing to be sure that all is installed correctly:

$ dotnet --info

If this is not the first .NET SDK on the machine, you will have to most likely redirect the previous version to the new one. Create JSON file global.json in your user's root folder with following content:

{
  "sdk": {
    "version": "2.1.300"
  }
}

Then I have created the new application:

dotnet new console -o myapp

and started it:

dotnet run

After a while you will get following result:
61218_myapphello
Please note that running the application this way takes long (1 min) time on PI. This is because restorimg package process and compilation ist to heavy for such small device. But after build, you can bublish application and you will see it runs fast.


comments powered by Disqus