Here is how to install and setup Microsoft’s .Net Core 5 on Raspberry Pi, this tutorial covers installation for both 64 and 32 bit ARM architecture.

I am using Ubuntu 20.04, but Raspbian should work as well.

To check what OS architecture the Raspberry Pi is, run the following command.

uname -m

The output should be something like this. The example below shows an output of ARM 64 architecture.

aarch64

The reason we are doing this test is so we could download the appropriate build archive of .Net Core 5.

Downloading of the wrong architecture will not run on the Pi. It will throw an error that states “dotnet file or folder not found”.

Downloads for ARM 64.

The .NET SDK 5.0.101.

wget https://download.visualstudio.microsoft.com/download/pr/2add7523-39ec-413a-b8a7-24361cc4e599/30489ebd7ebcc723da48a64669860fd0/dotnet-sdk-5.0.101-linux-arm64.tar.gz

The ASP.NET Core Runtime 5.0.1

wget https://download.visualstudio.microsoft.com/download/pr/e12f9b23-cb47-4718-9903-8a000f85a442/d1a6a6c75cc832ad8187f5bce0d6234a/aspnetcore-runtime-5.0.1-linux-arm64.tar.gz

Downloads for ARM 32.

The .NET SDK 5.0.101.

wget https://download.visualstudio.microsoft.com/download/pr/567a64a8-810b-4c3f-85e3-bc9f9e06311b/02664afe4f3992a4d558ed066d906745/dotnet-sdk-5.0.101-linux-arm.tar.gz

The ASP.NET Core Runtime 5.0.1

wget https://download.visualstudio.microsoft.com/download/pr/11977d43-d937-4fdb-a1fb-a20d56f1877d/73aa09b745586ac657110fd8b11c0275/aspnetcore-runtime-5.0.1-linux-arm.tar.gz

Creating the required directory and extracting these archives into the folder.

This folder is created as a hidden type because we don’t need to have the folders listed or shown in the file manager, this is the location where the executable and libraries of .Net are stored. If you want to change the location, feel free to do the required changes.

mkdir ~/.dotnet/

Extracting the archives to the .dotnet folder.

tar -xvf dotnet-sdk-5.0.101-linux-arm64.tar.gz -C ~/.dotnet
tar -xvf aspnetcore-runtime-5.0.1-linux-arm64.tar.gz -C ~/.dotnet

Setting up dotnet to work with bash.

Open the .bashrc file and add the following lines below, for this we are using nano, but you can use any editor of your choice.

nano ~/.bashrc

Add the lines below to the end of the .bashrc file.

export DOTNET_ROOT=$HOME/.dotnet 
export PATH=$PATH:$HOME/.dotnet

Save the file, by pressing Control + X + Y.

You can close this terminal session or SSH connection when you re-login you will have dotnet working.

If you want to continue with the same ssh or terminal session run this command and follow the other steps listed below.

source ~/.bashrc

Testing to see if it works correctly.

Let’s check the dotnet version.

dotnet --version

The output should be something similar to the one below.

ubuntu@pi:~$ dotnet --version
5.0.101

Let’s create our first dotnet project. This command will create a console application with the folder and project name myApp.

dotnet new console -o myApp

Compiling the application and running it.

cd myApp
dotnet build

The output should be something similar to this.

ubuntu@pi:~/projects/myApp$ dotnet build
Microsoft (R) Build Engine version 16.8.0+126527ff1 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  All projects are up-to-date for restore.
  myApp -> /home/ubuntu/projects/myApp/bin/Debug/net5.0/myApp.dll

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:20.41

Now let’s run the app.

dotnet run

The output will be like the one below.

ubuntu@pi:~/projects/myApp$ dotnet run
Hello World!

If you want to have a complete development environment with an IDE like interface like Microsoft’s Visual Studio Code. Follow the guide listed below to setup Code-Server on Raspberry Pi.

Thank you for taking the time to read this article, have a great new year.

Darryl Dias

Iā€™m Darryl. Iā€™m a 3D Generalist, Web Developer and Linux enthusiast. On this site I share my insights, tips and tricks, tutorials, methods and best practices.

Join the Conversation

12 Comments

  1. Thanks for the perfect explanation.
    Juggled with snapd dotnet-sdk, so removed it and finally this post helped me install dotnet in my Pi. šŸ™‚

    1. Unfortunately I have few projects of dotnet core 3.0/1 as well and now when I try to run those projects it fails and complains to install required framework.

      Is it possible to install multiple dotnet frameworks in Pi? As generally in Windows everything is managed by installer and backward compatibility is almost there.

  2. Hi Darryl,
    Thank you so much for this post. Very clear and straightforward. Just on the lines to extract the files with tar, It looks like it needs a trails slash, after ~/.dotnet (~/.dotnet/)

    Good job!

  3. Hi Darryl, thanks for the info.
    I can see running command line programs in the .NET5, but is there a way to also create UI’s as in Windows, to control GPIO hardware, etc. on the Pi?

    1. Hi Tony, .NET5 for Linux does not offer or officially supports creation of GUI application, but with third party tools and libraries it might be possible.

      I looked this up and came across this project, which might help you create GUI apps for Linux using .NET5 for Linux: https://avaloniaui.net/

      I believe .NET6 will support GUI Linux application creation with the help of MAUI.

      https://devblogs.microsoft.com/dotnet/introducing-net-multi-platform-app-ui/

      Thank you for the comment, if you have more questions feel free to reply to this thread.

  4. After following your guide, Im got the next crap:

    pi@raspberrypi:~ $ ls
    bash: ls: command not found
    pi@raspberrypi:~ $ man ls
    bash: man: command not found
    pi@raspberrypi:~ $

    What I do wrong ?

    1. I am not sure at what point you started getting that error, but if you delete the “.bashrc” remove everything in that file that should fix the issue.

      Let me know if this tip helps you

Leave a comment

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