Language: EN


How to install .NET on Raspberry Pi

We continue with the tutorials dedicated to .NET, seeing how to install .NET easily on a Raspberry Pi 2 or higher, or Zero 2 W.

In the previous post we saw how to install .NET on a computer with Ubuntu. This time we are going to see how to install it on a Raspberry Pi taking advantage of .NET’s ability to run on different architectures.

.NET is available on ARM-7 and higher architectures. This means it is available on Raspberry 2, 3 and 4 and Zero 2 W. However, it will not work on Raspberry PI 1 and Zero W.

In the case of Raspberry Pi, it will not be as simple as in Ubuntu, since .NET is not available in the platform’s package managers. To install it, the easiest way is to run the dotnet-install script, which we can do with the following command:

curl -sSL | bash /dev/stdin --channel STS

Where --channel indicates the version number we want to install. We can use,

  • STS - most recent Standard Term Support release
  • LTS - most recent Long Term Support release
  • A.B - Version A.B (for example 6.0)

It is advisable to add the .NET path to the PATH environment variable so that we can use it from any folder. To do this, we simply do,

echo 'export DOTNET_ROOT=$HOME/.dotnet' >> ~/.bashrc
echo 'export PATH=$PATH:$HOME/.dotnet' >> ~/.bashrc
source ~/.bashrc

Once .NET is installed, we can check that it has been installed correctly by running this command, as we saw in the previous post.

dotnet --version

Which should display the version of .NET that we have installed. We can also list the SDKs and runtimes that we have installed on the computer with these two commands

#list sdks
dotnet --list-sdks

#list runtime
dotnet --list-runtimes

According to Microsoft, this installation method through the script is only recommended for server installations. However, it is the best way I have found to install it easily on the Raspberry Pi. If I find a better way at some point, I will update the post.