ASP.NET Core 2.0.0-beta on a Raspberry Pi 3

At the end of 2015 I’ve tried to install ASP.NET vNext (later renamed to core) on a Raspberry Pi, but recently .NET Core 2.0.0-beta version came out and some people already had a play with this on an ARM32 environment. Arranging myself a Raspberry Pi 3 and trying this out was next!

  1. The environment
  2. Prepare the Raspberry Pi 3
  3. Create a project on the Windows environment
  4. Running the application on the Raspberry Pi 3
  5. Running a MVC webpage
  6. Running a WebAPI project
  7. Conclusion

The environment

Via https://github.com/dotnet/core/blob/master/samples/RaspberryPiInstructions.md I found easy instructions to accomplish this.

Used versions of software/hardware:

  • Raspberry Pi 3
  • 16GB SanDisk microSDHC (Class 10)
  • Ubuntu MATE 16.04.2 LTS
    • Linux hostname 4.4.38-v7+ #938 SMP Thu Dec 15 15:22:21 GMT 2016 armv7l armv7l armv7l GNU/Linux
  • .NET Core on the Raspberry Pi
    • Version: 2.0.0-beta-001663-00
    • Build: da54fbb7911c7ed584bfff54cdf223617959df6c
  • .NET Core on my Windows machine
    • Version: 2.0.0-alpha-005165
    • Commit SHA-1 hash: 4a0724e136

Downloaded the builds for Windows and Raspberry Pi from https://github.com/dotnet/core-setup#daily-builds

Prepare the Raspberry Pi 3

1. Install the prereq packages via:

sudo apt-get install libunwind8 libunwind8-dev gettext libicu-dev liblttng-ust-dev libcurl4-openssl-dev libssl-dev uuid-dev

2. Get dotnet 2.0.0-beta via

wget https://dotnetcli.blob.core.windows.net/dotnet/master/Binaries/Latest/dotnet-ubuntu.16.04-arm.latest.tar.gz

After extracting it (oops in the /home/pi directory), the ./dotnet command will work and output it’s information

Create a project on the Windows environment

Create a new project via the commandline

Change the following parts in the .csproj file

Run dotnet restore

Publish the application for our runtime

The guide mentions that an .exe should be build, but although my configuration states the OutputType as Exe, I still get a .dll file. Also in the publish directory no .exe file is to be found.

Running the application on the Raspberry Pi 3

Copying all the build output to the Raspberry Pi 3

Running the published application 😀

Running a MVC webpage

Next try is to get a MVC application running on the Raspberry Pi 3 using the 2.0.o-beta version of .NET. It turned out to be as easy as the console application.

I choose a MVC application, don’t get confused at the directory name I picked

Before the dotnet restore command, I changed the following lines in the .csproj file. I did not change any of the PackageReference versions

Running the application from the application directory

On the 7″ external display on the Raspberry Pi 3, the webpage is visit-able (is that a word?)

Bare in mind, the first run it took over a minute to get the webpage, but after the startup all the other MVC pages where displayed within a second

The test project, with published release files, can be found on my github: https://github.com/timdows/webpages/tree/master/DemoNETCore2.0.0-betaRaspberryPi

Running a WebAPI project

I found out that some others had issues with running a WebAPI project: https://github.com/challe/dotnet-core-raspberry-pi/wiki/Setting-up-a-Web-API-on-a-Raspberry-Pi-3-(Ubuntu-16.04)-using-.NET-Core-2.x, that I found via https://github.com/stevedesmond-ca/dotnet-arm/issues/3.

Okay, lets try if this is still the case or I can just get it to work.

Create the webapi project

Change the same bits in the csproj file

After copying it to the pi, start it from the application directory

It is just running like a charm, the startup time was around 20 seconds this time

 

Conclusion

  1. There are a lot of changes since I tried beta8 on a Raspberry Pi, now it would be cool if not only Ubuntu was supported, but I guess that when .NET Core 2 is released also e.g. raspbian will be included.
  2. The documentation stated that an .exe file would be produced, that could be run without any other installation on a Raspberry Pi. In my case I got a dll that needed to be bootstrapped by the arm version of the 2.0.0-beta .NET Core version.
  3. The package references I used throughout the web apps, are not the latest. I found that 1.2.0-* is already in preview1, but as the dotnet new command did give me some older versions, and those versions worked, I just stopped there in the beginning.
  4. Quick testing with the 1.2.0-preview1 packages didn’t even allow me to run it on my Windows environment.

The next couple of months I’ll closely look at the status of other packages, but for now the fact that you can leave out Mono AND use an ARM32 environment looks promising more than ever!

11 thoughts on “ASP.NET Core 2.0.0-beta on a Raspberry Pi 3

Leave a Reply

Your email address will not be published. Required fields are marked *