Sorry for the hiatus, but I’m back now. I am crazy excited about .NET Core and I think it is going in an awesome direction. We use it at work and I wish I had more Raspberry Pi 2 & 3s laying around since they are capable of running it. The problem is that I still have ARMv6 Pi 1s and Zeros that need to be put to use! I worked this out a few years ago on my Pi 1, but the latest version of Mono that I could get on my Pi at that time was 4.0.2. That version can run older ASP.NET 5 projects, but not ASP.NET Core. I will show you how to get Mono 4.6.2, libuv 1.22.0, and ASP.NET Core 2.0 to all play nicely together on a Pi Zero.


First off, since I am using a Pi Zero, I needed either a USB Wifi dongle or an Ethernet adapter. I have used both but I prefer a wired connection since I plan to stream from this Pi in the future. This adapter worked perfectly right out of the gate. Then make sure you grab the latest version of Raspian Stretch to image your Pi’s SD card with. I used the Lite version since I am running headless. Remember that to communicate with the headless OS, enabling SSH is required. As directed,1 create a blank text file named “ssh” on the root of the Boot partition on the SD card. Further, if you are using WIFI, you need to create a text file named “wpa_supplicant.conf”. Copy the following text in that file and update at a minimum your ssid and psk:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev


Now that we can bash, let’s install Mono. This is where it used to be difficult. As I mentioned previously, when I first started playing around with ASP.NET, the default version of Mono on Rasbian was 3.2.8. I attempted to build Mono from source but ran into several problems, most likely because my ARMv6 Pis do not support hard floating point. At that time, I found two particularly helpful posts on how to point to a Jessie-specific Mono 4.0.2 repository which enabled me to run ASP.NET 5 applications.

Fast-forward and now Rasbian’s Mono version is 4.6.2, so we can just install it! Easy-peasy:

sudo apt-get update && sudo apt-get upgrade
sudo apt-get install mono-complete

Now check out your Mono version. We’re all set!

pi@raspberrypi:~ $ mono --version
Mono JIT compiler version 4.6.2 (Debian
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors.
        TLS:           normal
        SIGSEGV:       normal
        Notifications: epoll
        Architecture:  armel,vfp+hard
        Disabled:      none
        Misc:          softdebug
        LLVM:          supported, not enabled.
        GC:            sgen

At this point, it was important for me to ensure my old ASP.NET 5 application still worked. So I tried installing DNVM as outlined by dave dot ninja here. I hit a roadblock at the first command:

curl -sSL | DNX_BRANCH=dev sh && source ~/.dnx/dnvm/

Running the produces a 404 Not Found error. Sure enough, the URL for in that script no longer exists. I knew DNVM is deprecated, but obsolete or not, this is the only way to run ASP.NET 5 on a Pi Zero. I found someone else looking for this, as well as confirmation that I would have to reference it in commit-specific links. Going back to Scott Hanselman’s post mentioned above, I modified his steps (his example was for the older KVM tool) to install the latest version of DNVM I could find (which happened to be tagged 1.0.1):

sudo apt-get install git
git clone --branch 1.0.1
cd Home/

At this point, we know the script copied to /home/pi/.dnx/dnvm/ by is invalid, so I just overwrote it with the from the repository and continued with the installation.

cp /home/pi/.dnx/dnvm/
source /home/pi/.dnx/dnvm/
dnvm upgrade
dnvm list

You should see your mono runtime listed:

Active Version              Runtime Architecture OperatingSystem Alias
------ -------              ------- ------------ --------------- -----
  *    1.0.0-rc1-update2    mono                 linux/osx       default

As Scott further described, the “Kestrel” web server requires the libuv library. I modified his steps to build the current version of libuv. But trying to run “dnx run” yielded an error that Mono was unable to load DLL ‘libuv’. Argh. I looked back at some notes and remembered that Mono is looking for the library in /usr/local/lib. Added the symbolic links to that folder instead but still no dice. I went to my Pi 1 and verified that his steps worked for Mono 4.0.2 with /usr/local/lib and libuv 1.9.1. Back to dave dot ninja’s updated DNVM steps, I realized he had posted slightly different steps for building libuv. This worked perfectly (modified with updated version):

sudo apt-get install automake libtool curl
curl -sSL | sudo tar zxfv - -C /usr/local/src
cd /usr/local/src/libuv-1.22.0
sudo sh
sudo ./configure
sudo make
sudo make install
sudo rm -rf /usr/local/src/libuv-1.22.0 && cd ~/
sudo ldconfig

Now let’s see if we’re up:

cd Home/samples/1.0.0-rc1-update1/HelloMvc/
dnu restore
dnx web

If you see this then you are there!

Hosting environment: Production
Now listening on: http://*:5004
Application started. Press Ctrl+C to shut down.

Browse to your Pi’s IP address at the port listed above. After a minute or so you should see the sample ASP.NET 5 MVC website!


Awesome. Now you can create an ASP.NET Core project in Visual Studio and run it on your Pi 1 or Pi Zero. Here is a great tutorial on how to accomplish this:

I am planning a follow-up post to show how to create a simple ASP.NET Core website that streams video from the Raspberry Pi camera.

Under-Counter LEDs on an ESP8266 - Part 1

Hosting a FastLED driver and webserver to control it on an ESP8266. Continue reading