Scott Hanselman

How to run ASP.NET 5 Beta 3 or GoLang on a Raspberry Pi 2

March 03, 2015 Comment on this post [50] Posted in Hardware | Open Source
Sponsored By
Hanselman's Desk of Hardware

Hanselminutes and CodeNewbie are teaming up to produce two new podcast episodes a week for the month of March, featuring incredible makers in the hardware space. There will be new content every weekday in March, so bookmark and join us!

  • CodeNewbie is the most supportive community of programmers and people learning to code. Tune in every week for stories about people on their coding journey.
  • Hanselminutes: Fresh Air for Developers is a weekly talk show that brings interesting people together to talk about the web, culture, education, technology and more.

Our hashtag for this event is #MarchIsForMakers and YOU, Dear Reader, can help us out by being our Street Team.

Share our website!

...with friends, kids, teachers, family, anyone you think my be benefit from learning about hardware and today's maker culture.

This is just Day 1! At the end of March we'll have as many as 10 great podcasts, amazing guests, Live Google Hangouts, blog posts, Twitter Chats on Wednesdays, and a huge collection of links and projects for you to explore.

How to run ASP.NET Beta 3 running on a Raspberry Pi 2

I love Raspberry Pi, the tiny $35 computer. I've gone through 6 at least count. Have they died? Not at all! They've been gifted forward. Right now I've got one running my 3D Printer, one running as a media center, and a Raspberry Pi 2 that my kids are using as their primary computer. There's so many Raspberry Pi projects - How can you not love a tiny computer?

This actually a dual tutorial/how-to. I've been so impressed with the Raspberry Pi 2 I've wanted to see how far one can take it. It's still a modest little machine, but it's definitely twice as fast or more in single-tasking and perhaps 6x faster in multitasking in my experience than the previous Raspberry Pi.

Basic Raspberry Pi set up

I use the Raspbian Operating System image for my Raspberry Pi 2. It's a Debian Wheezy image for techies, that's a Unix for non-techies.

I use this hardware (these are Amazon links) that I put together myself, although you can get a kit that includes memory, power, wifi, cables, case, etc.

You can get the disk image and follow the setup instructions here. I also added TightVNC so I could remote into my Raspberry Pi from my desktop. This also allowed me to run it "headless" without a monitor, but it's up to you.

You can see me VNC'ed into my Raspberry Pi 2 here. Of course, you can always connect it to your monitor or TV.

VNC'ed into a Raspberry Pi

I wanted to see how hard it would be to run .NET on this Raspberry Pi. Depending on how deep you want to go, it's not hard at all.

Running ASP.NET on a Raspberry Pi 2

NOTE/DISCLAIMER: This is a point in time. It's a beta/daily build of an early thing. I'm sure this will get down to a few simple lines in the future, so don't panic thinking that ASP.NET on Linux will suck. It's early.

Frist, you can get an old (3 years old) version of the open source Mono runtime with the stable standard repositories

sudo apt-get mono-complete

And this will get you version 3.2.8. You can do basic stuff. Make a HelloWorld.cs and run it with

gmsc HelloWorld.cs
mono HelloWorld.exe

Debian likes to be very stable, I'm told, so if you want to get a very NEW version of Mono like version 3.10 (that's "Three Point Ten") and as such, run things like ASP.NET 5, you'll need to do a little more work.

UPDATE and IMPORTANT NOTE: There's two options here. Build Mono from source, or use a custom repository from the Mono folks.

Option 1: Install Mono from The Mono Project's repositories

The Mono Project has their own repository for Debian distributions like Raspbian Wheezy. If you've put on an early mono, you'll want to sudo apt-get remove mono-complete first to tidy up.

Per their instructions from the Mono site, you'll then

sudo apt-key adv --keyserver --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF 
echo "deb wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
sudo apt-get update && apt-get upgrade
sudo apt-get install mono-complete

And you should be all set!

Option 2: Build Mono from Source (slow and advanced and of questionable value)

You could git clone the Mono repository and build it. I found this process slow, so I downloaded the source from an archive instead, then unzipped it into a folder.

mkdir ~/monosource
cd ~/monosource
tar -xjvf mono-3.10.0.tar.bz2

Then here's a bunch of prerequisites I needed, plus htop because I like it.

sudo apt-get install build-essential autoconf automake binutils libtool libglib2.0-dev libxrender-dev libfontconfig1-dev libpng12-dev libgif-dev libjpeg8-dev libtiff5-dev libexif-dev gettext libcairo2-dev htop 

Then start the build. This too an hour or so, and is dependent on the speed of your Pi AND the speed of your SD card. It should be a Class 10 if possible.

./configure --prefix=/usr/local; sudo SKIP_AOT=true make; sudo SKIP_AOT=true make install;

Note this is three lines in one. Do a sudo reboot when you're done. If you can run mono -V and see version 3.10.0 then you're in a good place.

Mono 3.10.0 on a Raspberry PI

Adding ASP.NET 5

You can add ASP.NET 5 at this point by downloading the samples directly from Github and running the "" to setup the ASP.NET runtime manager.

mkdir ~/sources/aspnet5 
cd ~/sources/aspnet5
git clone git://
sh ~/sources/aspnet5/
source ~/.k/kvm/
kvm upgrade

Then per this GitHub issue you need to tell your system about the SSL certs for NuGet to restore correctly.

sudo $CERTMGR -ssl -m
sudo $CERTMGR -ssl -m
sudo $CERTMGR -ssl -m

mozroots --import --machine --sync

Then go to one of the samples like ~/sources/aspnet5/home/samples/HelloMvc and run "kpm restore." Note this uses about 400 megs of RAM for a minutes so you'll want a newer Raspberry Pi.

Running kpm restore on Raspberry Pi

NOTE: Make sure the sample version in project.json match your local runtime version. I needed to update version strings to beta3 to match what "kvm list" said. I'm sure this will get fixed soon.

The "Kestrel" web server uses libuv, an HTTP library. Here is how to build libuv. I found this on Punit Ganshani's blog, which I'm actually wishing I'd found earlier in this blog post. ;)

sudo apt-get install gyp
tar -xvf libuv-v1.0.0-rc1.tar.gz
cd libuv-v1.0.0-rc1/
./ -f make -Duv_library=shared_library
make -C out
sudo cp out/Debug/ /usr/lib/
sudo ln -s /usr/lib/ Then run

Then run "k kestrel" and hit the port mentioned in the project.json.

ASP.NET 5 Beta 3 on a Raspberry Pi 2

How to run Go on a Raspberry Pi 2

I wanted to Go running as well. Go has fewer dependencies but no official ARM builds. The Raspberry Pi 2 is an ARMv5. However, a very kind gentleman named Dave Cheney has been building and hosting his own unofficial ARM tarballs for Go. You take the instructions from the GoLang site and his links and you're all set on your Raspberry Pi or Pi 2.

Here's what I did for a Raspberry Pi 2.

sudo tar -C /usr/local -xzf go1.4.2.linux-arm~multiarch-armv7-1.tar.gz

Then, add it to your path, or .profile, or whatever.

export PATH=$PATH:/usr/local/go/bin

Make a HelloGo.go, compile and run.

Go on a Raspberry Pi

Personally, I'd love to see "dotnet" be as easy to get running on Linux as Go.

package main

import "fmt"

func main() {
fmt.Println("Hello Go on Raspberry Pi 2")

The Raspberry Pi is just a little joy. It's a lot of fun and has a lot of potential. Definitely pick up some for the kids (yourself.)

Don't forget, visit, tell your friends and tweet us at #MarchIsForMakers!

Related Links

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service
March 03, 2015 13:42
Cool. Thanks for all the heavy lifting. If I ever pick up a Pi 2, I know exactly where I'm coming first.
March 03, 2015 14:12
As always a great article, but I have one question:
Why did you build Mono from source and not use their repos (see here)?
I just installed Mono 3.12 on my Pi2 running Raspbian that way and it was much quicker (and easier IMO) then building it from source (as I did it that way in the past)...

Hope to see you at //build/ this year (again)?
March 03, 2015 15:16
I ordered a PI 2 last week (should arrive today) for this very purpose. This article should save me countless hours of effort. Thanks
March 03, 2015 16:15
You probably wanted
git clone --depth 1
March 03, 2015 17:53
Why not use docker?
March 03, 2015 18:45
"sudo apt-get install mono-complete"

On Raspian currently installs mono 3.2.8
March 03, 2015 20:28
Slim - Yes, that's very old. I want 3.10.
Christoph - Likely my own ignorance! When was that setup? I didn't realize that also worked on the pi. I will try and update my post.
March 03, 2015 20:34
Hello there!
Amazing post, thank you for sharing..

I am trying to make this thing work for about two days by now and i am still stucked at:
System.InvalidatOperationException: No service for type 'Microsoft.Framework.Runtime.IServiceManifest' has been registered.

Can somebody please take whole raspbian / arch linux image with working 5 and upload it somewhere on google disk or anything similar? I would be very greatful for this! :)
March 03, 2015 20:46
I think it could be super usefull also for other peoples. Compiling whole mono take veeeery long time, and kvm upgrading can be a problem on older rpis (out of memory exception)
March 03, 2015 21:26
Thanks Scott, I was reading 3.10 as 3.1 dur. I went to 3.12 using the repo from Christov, cheeers!

Scott in your guide there's the step:

sh ~/sources/aspnet5/

where the script is cloned to:

sh ~/sources/aspnet5/home/

and the kre directory isn't quite right, it should be:

source ~/.k/kvm/

I didn't manage to get any further though, tried changing the version numbers to beta3 in the project.json but still get:

System.NotImplementedException: The requested feature is not implemented.
at Microsoft.Framework.PackageManager.PackageUtilities+<OpenNuspecStreamFromNupkgAsync>d__1.MoveNext () [0x00000] in <filename unknown>:0

When running 'kpm restore' on any of the samples.
March 03, 2015 21:34
Ah, cracked it. I'd started at the top with 'sudo apt-get install mono-complete', I needed to 'apt-get remove mono-complete' before re-installing after adding the repo.

Works now, thanks for the guide!

Tempted to try doing it again with Docker now... :)
March 03, 2015 21:37
Congratulations Slim.
Can you please upload your working image of your sd card somewhere to web?
March 03, 2015 21:48
Nice job, Slim! Updating the post now.

Jon - Baby steps, but you're right, Docker for Raspberry Pi is a very reasonable solution! I'll see what I can do.
March 03, 2015 22:48
Hi Hope. Would rather not upload my image as it's got all sorts on there. You don't need to recompile mono as mentioned above.

What are you trying to get that error, perhaps we can help?
March 03, 2015 23:05
Hey Scott, one more small thing; if you're on a pi2, it's ARM7 so you can use that build of go:
March 03, 2015 23:15
Slim i think my biggest problem is that I have only old Raspberry Pi B which has lesser ram then new raspberries. When i run "kpm restore" it fails, because of OutOfMemoryException.

I tried to run kpm restore on another repository: and it finished OK. But when i try to run project by "k web" or "k kestrel" ill get an exception:

System.InvalidOperationException: No service for type 'Microsoft.Framework.Runtime.IServiceManifest' has been registered.

I also tried to increase size of swap file and then run kpm restore, but with no good result. I think 5 should work also on older raspberies, am i correct?

Thank you for helping me :)
March 03, 2015 23:29
Fantastic post Scott!
Thanks so much for this. Bookmarking and ordering my Raspberry Pi as we speak. Also super excited about #MarchisForMakers.

March 03, 2015 23:46
hope - Did you try kvm upgrade first?

Slim - Fixed, typo!
March 04, 2015 0:00
Scott - sure, it says that i have actual version.
March 04, 2015 1:36
Running "Linux raspberrypi 3.18.8-v7+ #761 SMP PREEMPT Fri Feb 27 15:48:09 GMT 2015 armv7l GNU/Linux", I had to deviate on certain parts of your instructions:

1) sh ~/sources/aspnet5/ -> sh ~/sources/aspnet5/home/
2) CERTMGR=/usr/local/bin/certmgr -> CERTMGR=/usr/bin/certmgr
3) mozroots --import --machine --sync -> sudo mozroots --import --machine --sync

And the biggest change:
before running ./ -f make -Duv_library=shared_library , I had to execute this command:
git clone build/gyp
March 04, 2015 3:08
I mean, it looks like these instructions were produced by decomposing the Dockerfile, so I don't know why you wouldn't simply encourage users to use the Dockerfile. (Or a better one, I have some qualms with the microsoft/aspnet image).

Docker is one of those tools that pays to take the few hours to learn it.
March 04, 2015 10:10
It should be much easier to run .NET on the Raspberry Pi 2 once Windows 10 (the IoT edition?) is available for it.
March 04, 2015 11:06
I also can't wait to try Win10 on the Pi2. Hopefully they manage to create a better USB driver, as our devices here don't work (well) with the one from Raspbian...
March 04, 2015 12:34
"Hm" - No, I've never looked at the docker image. Do you think this is something that should only be done in Docker from now on? I'll do some research!

Harold - I hope so!

jodegreef - Ah! I ended up doing sudo apt-get install gyp. I'll add that.
March 04, 2015 15:41
I did spend some time looking at doing this in Docker, and it's not straight forward. As far as I can tell, there's no support in Docker for ARM so you have to use a modified version. It looks like Docker doesn't consider the target architecture, and is tied to x64 so the usefulness of this on the pi is dubious.

I'm not a Docker expert, but it looks like it's not ready for Pi yet.
March 04, 2015 15:42
Yes, also looking forward to Win10, but it looks like we're going to get the 'for devices' version, so expect limited functionality.
March 04, 2015 16:02
Hi, so is there somebody willing to upload his working asp.5 sd card image? i can write a manual how to do it. it is really simple process.
March 04, 2015 16:38
Hope, I'm not sure an image would solve your problem. You'll still have to sync dependancies so will still get the out of memory error. Why not invest in a pi2, they're cheap!
March 04, 2015 16:44
Slim I mean image with actually working So on this image should be all dependencies already synced.
I will sure buy PI2, but i would feel sorry for old raspberies, they should also experienced hosting, at least once in their lives :))
March 04, 2015 16:49
You will need to sync dependencies on a per project basis. An image could have the dependencies synced for the sample projects but any changes to them or new projects and it'll fail again.
March 05, 2015 4:36
Thank you Scott!

I now have ASP.NET 5 Beta 3 running on my Pi Model B (512 MB RAM).

To accomplish this, I followed your instructions, with some slight differences (compiled Mono 3.12, libuv 1.4.2 and used dd/mkswap/swapon to add some extra swap space for 'kpm restore').

Attempting to use the Debian Mono repository on the Model B does not work (because the packages require the ARMv7 arch). I really recommend nobody try this - it wasn't fun to remove/purge partially installed packages when the uninstallation scripts won't run.

The mozroots command would also fail "Couldn't retrieve the file using the supplied information" so I downloaded certdata.txt and hosted it locally on IIS, and changed my hosts file so mozroots would request the file from my local Windows box. I'm guessing it times-out too prematurely for a slow Pi.

It seems to start-up HelloMvc fast enough (10 seconds max), and the page on :5004 is served up in under 300ms.

Thanks again. My Raspberry Pi Model B just got a little more awesome! :-)
March 05, 2015 8:47
Fantastic post, Ordering ym Raspberri Pi2.
March 05, 2015 13:26
In my case, the routing was missing in the Startup.cs file, so I could not load the HomeController, which was the point of the HelloMVC sample. Adding the right routing configuration did make it work.
March 05, 2015 17:04
I ran into one issue with getting mono using Option 1. The command sudo apt-get update && apt-get upgrade failed due to lack of permissions. I am logged in using VNC (non-root user) so it appears the apt-get upgrade failed due to permissions issues. When I ran sudo apt-get upgrade it ran correctly. It looks like only the apt-get update was run with elevated permissions.
March 06, 2015 12:24
As mentioned by jodegreef above, the HelloMvc web app doesn't add any routes - so it just displays the MVC welcome page.

In Startup.cs, after changing "app.UseMvc();" to:
app.UseMvc(routes =>
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");

The /Views/Home/Index.cshtml page on :5004 is served up in under 40ms - which is much better than the 300ms I reported above (which was for the welcome page).

That's pretty awesome on a Pi Model B - even if HelloMvc is just a debug build.

Screenshot @

March 06, 2015 15:37
I also got a new PI (arrived yesterday) and am looking forward to digging in with it and being able to run ASP.NET on it seems an interesting thing to try as a first project.

I find the concept fascinating - if there's ever a good reason to have .NET run on Linux, iOT and small devices are surely a major one!

But... I wonder whether this will be a viable thing to do in the future. The issue I see is that there will need to be an eco system that supports all the cool things you can do with the hardware and you'll need some sort of low level interface to make that happen. How will that work if you're running .NET on Linux and Linux hardware? How do you hook into the underlying hardware and/or will there even be a .NET eco-system alongside the Node's, Pythons and C++'s? A lot more needs to happen than just 'support .NET on 'nix', no?
March 07, 2015 1:29
As @Slim mentioned, Docker doesn't support ARM at the moment. There is supposed to be some alternative in the next version of Debian, Jessie, but there's no Raspbian for it yet and I was warned against manually upgrading the kernel as it could cause issues.

On my Pi B it takes FOREVER to load Kestrel (I think I'm using ASP.Net beta 2) after booting (5+ minutes) although once the site is up and built, refreshing the page is rather fast. I wonder if that's my own fault for building Mono from source (which took 6+ hours, so your 6x speed number is anecdotally accurate!)

One really annoying issue that I encountered when setting kestrel to start at boot (in an init.d script) is that since 'k' waits for Console.ReadLine (aka stdin) it can close prematurely if started in the background (specifically, I think a SIGTTIN signal is sent to the process when it tries to ReadLine which is unhandled and terminates kestrel). I was finally able to fix it using a shell script from a related issue that spawns a fifo for kestrel to listen on.

I'm absolutely amazed at how far .Net has come lately now that it can run web pages from a RasPi.
March 07, 2015 2:45
This isn't working for me. When I run "k kestrel", I get the following error:

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Framework.ConfigurationModel.IConfiguration, Version=, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
File name: 'Microsoft.Framework.ConfigurationModel.IConfiguration, Version=, Culture=neutral, PublicKeyToken=null'
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
March 07, 2015 3:09
OK, got it; I had missed the part where you said to change the dependencies to beta3...
March 08, 2015 11:39
Took a few hours but finally got there :)

Few deviations:

  • I ended up with mono 3.12 and not 3.10.
  • When getting the nuget certificates I removed the $CERTMGR variable and replaced with certmgr.

  • Thanks for putting this together,
    March 10, 2015 22:28
    I absolutely love the Raspberry Pi. Even with the old Mono runtime it's been able to run all of the applications I've written for it (in Visual Studio 2013 compiled on my Windows machine and pushed to the pi's with a build script).

    I currently have two, one running a security camera (I was going to write my own but why re-create the wheel, I used apt-get motion and fswebcam and then wrote .net programs to polish off the captures like I want them and roll them up into something that's easy and quick to consume). On my Windows box I've used AForge to interpret what's on the images to figure out which ones maybe more significant (like, if it can find a face). I haven't yet tried an AForge PCL port I found that doesn't use the Windows API but it is in my near future to try.

    Oh, and the other is running RetroPie with EmulationStation. EmulationStation is in my opinion a very elegant looking shell. In fact I like it better than most actual game stations (it wraps the RetroPie project together). I have this one also setup to be a make shift security system if I want to turn it on, I just leave a web-cam plugged into it. The EmulationStation code is available on GitHub also (using it I was able to load up a Commodore 64 app from the shell that I wrote when I was 7 back in 1985 which does nothing but make me smile with nostalgia).

    My only complaints I have had with Linux is general is setting up Wifi can be a headache and different between every install as to what gets it working (throw something in like having multiple routers and it gets touchier and touchier, although not impossible by any means, clearly got it working after tweaking configs over an hour).

    I love reading your posts Scott. Best to you!
    March 19, 2015 9:29
    Fantastic post, Scott! I've been experimenting with my new Raspberry Pi 2 and just put together a GitHub repo with scripts to do all of these steps, including a PDF ebook with instructions for a noob on how to setup a Pi and then get Mono and ASP.NET installed. Check out
    March 25, 2015 9:36
    According to pmap on Ubuntu the HelloMvc app is using 100 MB. That seems like a lot of memory. And a lot of that is taken up by Roslyn. I'm not so sure having the ASP feature of not requiring compilation is always a good idea. Is there a way on Linux embedded devices that we can just compile the web site ala MVC4/5 and not have to load up MBs of Roslyn dlls?
    April 01, 2015 4:40
    Keith Hill - Apparently "dnu publish --no-source" will remove Roslyn and save memory, soon.
    April 01, 2015 6:55
    Scott - That's excellent news! Thanks for following up.
    April 19, 2015 17:15
    Nice tutorial! I've got it running on a Raspberry B+ with Raspbian jessie (minimal image). I had a couple of issues installing Mono debs from the Xamarin repository: apt-get threw an exception for some reason and left me with a bunch of half-installed packages. Compiling and installing from source worked instead, but prepare yourself for hours and hours of compiling. Also, I installed the latest version of libuv (1.4.2) using the same procedure described in the tutorial. Finally, if you are using Raspbian I suggest using checkinstall (latest version from git) in substitution of "make install".
    Now it's time to learn some ASP.NET!
    April 21, 2015 7:19
    Also, on the Mono install. I found that I got failures unless I added sudo to each of the commands...

    sudo apt-get update && sudo apt-get upgrade

    Your example above leaves sudo off the second command.

    May 12, 2015 3:29
    Awesome articular Scott, I've been attempting to get SignalR to run on the Raspberry PI without success, would love to know if you or anyone has managed to run a self-hosted SignalR server.

    Keep up the great work; loving all the new ASP.NET 5 MVC 6 stuff coming out of the teams not to mention all the IoT work :D
    May 16, 2015 17:45
    Using Option 1 to install Mono doesn't work :-(

    I get this:

    pi@raspberrypi ~ $ sudo apt-get install mono-complete
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    Some packages could not be installed. This may mean that you have
    requested an impossible situation or if you are using the unstable
    distribution that some required packages have not yet been created
    or been moved out of Incoming.
    The following information may help to resolve the situation:
    The following packages have unmet dependencies:
    mono-complete : Depends: mono-devel (= 4.0.1-0xamarin5) but it is not going to be installed
    E: Unable to correct problems, you have held broken packages.
    pi@raspberrypi ~ $

    Please update guide, as I would really like to get i working :-)
    May 17, 2015 11:24
    Hey Rasmus Christiansen
    If you got this problem, you have an old version of Mono on your system. Remove everthing that Looks like Mono with sudo apt-get remove mono... where "..." is the suffix which you find when you press "Tab".

    Comments are closed.

    Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.