View on GitHub

.NET Core Chris

.NET Core on Raspbery Pi

How to install .NET Core on Raspberry Pi

I'm a big fan of Raspberry Pi computers. So I found out that a ARM build of .NET Core had been released. I had to try it!.

Items Required


Item Note
Raspberry Pi 2/3 Model B
microSDHC card Class 6 or Class 10 microSDHC card
USB Keyboard
Monitor

Install Ubuntu Server Image to SD Card

Start by downloading Ubuntu server for Raspbery Pi

I choose the Ubuntu Server Standard 16.04 torrent

Extract the img file from the zip and use Win32 Disk Imager to copy the image to the microsd card.

Configure Wifi or just use ethernet (Jump to Install .NET Core)

Insert the microSDHC card into the pi and connect the power to boot. (It will take some time to boot into the console - mine took 5 minutes!)

Login with ubuntu/ubuntu, then configure wireless networking.

Option A If you have a internet connection via ethernet.

sudo apt-get install wpasupplicant

Option B If you don't have a internet connection via ethernet:

Download

and copy onto a FAT32 formatted usb stick. Insert the stick into the and check deviceid
sudo fdisk -l
Create mount point and mount drive (Ubuntu server does not automount ootb)
sudo mkdir /media/external
sudo mount -t vfat /dev/sda1 /media/external/
Copy the files to the home directory and install:-
cp /media/external/*.deb /home/ubuntu/
sudo dpkg -i /home/ubuntu/libnl-3-200_3.2.27-1_armhf.deb
sudo dpkg -i /home/ubuntu/libnl-genl-3-200_3.2.27-1_armhf.deb
sudo dpkg -i /home/ubuntu/libpcsclite1_1.8.14-1ubuntu1_armhf.deb
sudo dpkg -i /home/ubuntu/wpasupplicant_2.4-0ubuntu6_armhf.deb

Configure Wifi SSID and Pre Shared Key (PSK)

sudo nano /etc/network/interfaces

add the following to the file:-

auto wlan0
iface wlan0 inet dhcp
wpa-ssid "SSID"
wpa-psk "WIFIPASSWORD"
Exit nano with Ctrl-X and confirm changes, then reboot.
sudo reboot
Wifi should now be working!!

Install .NET Core

Install the prereq packages for .NET Core. & core-setup

sudo apt-get install libunwind8 libunwind8-dev gettext libicu-dev liblttng-ust-dev libcurl4-openssl-dev libssl-dev uuid-dev
wget https://github.com/dotnet/core-setup/files/716356/dotnet-ubuntu.16.04-arm.1.2.0-beta-001291-00.tar.gz
mkdir /home/ubuntu/dotnet
tar -xvf dotnet-ubuntu.16.04-arm.1.2.0-beta-001291-00.tar.gz -C /home/ubuntu/dotnet
cd dotnet

Test the runtime with Hello World!

Create .NET Core Hello World App

I configured Visual Studio 2015 and created the app using instructions here My helloworld app consisted of:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace helloworld
{
    public class Program
    {
        public static void Main(string[] args)
        {
            Console.Write("Hello World!!" + Environment.NewLine);
        }
    }
}

Publish the helloworld app using Build -> Publish and open helloworld.runtimeconfig.json to edit the version field to the .NET Core on the target pi (run ./dotnet --version to find out)

{
  "runtimeOptions": {
    "framework": {
      "name": "Microsoft.NETCore.App",
      "version": "1.2.0-beta-001291-00"
    }
  }
}

Then copy the published files to /home/ubuntu/helloworld using winSCP

To test the app!
./dotnet /home/ubuntu/helloworld/helloworld.dll
Hello World!!

You now have .NET Core running on a Raspberry Pi!! Enjoy!

Next Task is to setup ASP.NET by following this article