Here is how to install and set up 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 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
Code language: JavaScript (javascript)

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
Code language: JavaScript (javascript)

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
Code language: JavaScript (javascript)

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
Code language: JavaScript (javascript)

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 executables and libraries .Net are stored. If you want to change the location, feel free to do the required changes.

mkdir ~/.dotnet/Code language: JavaScript (javascript)

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/.dotnetCode language: PHP (php)

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
Code language: JavaScript (javascript)

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
Code language: JavaScript (javascript)

Now let’s run the app.

dotnet run

The output will be like the one below.

ubuntu@pi:~/projects/myApp$ dotnet run
Hello World!
Code language: JavaScript (javascript)

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

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

I compiled a list of software and services that I use to improve my workflow, here is the link to the list.

Darryl Dias

I’m Darryl. I’m a 3D Artist, Programmer and Linux enthusiast. On this site I share my insights, tips and tricks, tutorials, methods and best practices.

Join the Conversation

13 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

  5. Hi Darryl,

    I know really *nothing* about dotnet, I only know that I must run a dotnet application and that I must have dotnet in my setup. The application is an EEPROM programmer; it should run on any dotnet capable platform, connected to an Arduino and finally to the board where the EEPROM is installed.

    The setup is: Raspberry 4 —-(USB)—->> Arduino —->> 6502 computer

    The author of the application (https://github.com/Nectivio/65C02-Tool) simply claims that you must download and install dotnet Runtime and then run the application.

    I downloaded and *manually* installed dotnet as per MS instruction here:

    https://docs.microsoft.com/en-us/dotnet/core/install/linux-scripted-manual

    dotnet seems OK:

    [OUTPUT]
    pi@raspberrypi:~ $ dotnet –info

    Host (useful for support):
    Version: 5.0.13
    Commit: b3afe99225

    .NET SDKs installed:
    No SDKs were found.

    .NET runtimes installed:
    Microsoft.NETCore.App 5.0.13 [/home/pi/dotnet/shared/Microsoft.NETCore.App]

    To install additional .NET runtimes or SDKs:
    https://aka.ms/dotnet-download
    pi@raspberrypi:~ $
    [/OUTPUT]

    But when I try to run the application, the result is:

    [OUTPUT]
    pi@raspberrypi:~ $ dotnet Arduino/65C02-Tool/eeprom-programmer.sln
    Could not execute because the application was not found or a compatible .NET SDK is not installed.
    Possible reasons for this include:
    * You intended to execute a .NET program:
    The application ‘Arduino/65C02-Tool/eeprom-programmer.sln’ does not exist.
    * You intended to execute a .NET SDK command:
    It was not possible to find any installed .NET SDKs.
    Install a .NET SDK from:
    https://aka.ms/dotnet-download
    pi@raspberrypi:~ $
    [/OUTPUT]

    Do you think you can give me a hint on what’s wrong?
    Thank you,
    Andrea

Leave a comment

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