Installing .NET 6 on a Raspberry Pi Zero 2 W

Installing .NET6 on a Raspberry Pi can be quite easy, however with the different architecture of the Pi Zero 2 W some of the easier installs won't work. This post will show you a simple enough way of doing a .NET 6 install on a Pi Zero 2 W.

Installing .NET 6 on a Raspberry Pi Zero 2 W

At the time of writing this, Microsoft has released installation documentation for Linux as it isn't as simple as a Windows installer:

Install .NET on Linux Distributions
Learn about what Linux distributions support installing .NET on Linux.

However, the default Raspberry Pi OS package manager does not include .NET 6:

This leave us few options and the option I'll walk you through is the simplest way to use the install-dotnet.sh script.

Installing .NET 6 Via Script

✍️
Note: This is installing the runtime as I won't be developing on my Raspi. If you want to install the SDK, run without --runtime aspnetcore below
  1. Open a new terminal and run the install script. This installs and creates a hidden folder: /home/pi/.dotnet with the binaries
curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin -c Current --runtime aspnetcore
  1. Open .bashrc for editing
mousepad ~/.bashrc
  1. Export such that we can execute dotnet from anywhere in the terminal by pasting the following at the bottom of .bashrc to update the PATH
export DOTNET_ROOT=$HOME/.dotnet
export PATH=$PATH:$HOME/.dotnet

If you open a new terminal or run source ~/.bashrc you should now be able to run commands:

Maybe One Day It Will Be Easier, with Snap

Outside of the native package manager, Microsoft prefers using Snap as the method to install .NET.

Installing snap on Raspberry Pi OS | Snapcraft documentation
Snaps are containerised software packages that are simple to create and install. They auto-update and are safe to run. And because they bundle their dependencies, they work on all major Linux systems without modification.

Snap is similar to apt-get where you can install packages and they do have .NET offerings except not built for the Pi Zero 2 W architecture...

🤷 Or you know, maybe it will be added to apt-get one day.

To Conclude

I originally had a lot of pain installing .NET 6 on the Pi Zero 2 W because of it's slightly different architecture and my own lack of Linux knowledge. The above is easy enough to consume even for a Windows person like myself and I hope it proves useful for you too!