NET Core, now referred to as just “.NET” (starting from version 5), is an open-source, cross-platform framework for building various applications. You can install .NET on your Raspberry Pi running Raspberry Pi OS to develop and run applications directly on your Pi. In this guide, we will walk you through the steps to install .NET on Raspberry Pi OS.
Prerequisites:
- Raspberry Pi running Raspberry Pi OS (formerly Raspbian).
- An active internet connection.
- Access to the terminal (either directly on your Raspberry Pi or via SSH).
- A Raspberry Pi 3 or later is recommended, though earlier models may work with some performance limitations.
Step 1: Update the Pi OS
First we will make sure that we have the lastest version of Pi OS installed on our Raspberry Pi so as to avoid it package conflicts using the following command:
sudo apt-get update && apt-get dist-upgrade -y
This will update the package list and install the latest updates for your Raspberry Pi OS.
Step 2: Download the installation script
Raspberry Pi OS comes preinstalled with curl, so we will continue with using that to download the installation file provided by microsoft itself. Most of the linux distros come with with curl or wget installed, you can use either of them as per your convenience.
curl https://dot.net/v1/dotnet-install.sh
Step 3: Download and Install dotnet
Use the following command to download and install the dotnet core framework to the operating system:
sudo bash ./dotnet-install.sh --channel LTS --install-dir /opt/dotnet/
In the above command, we are using the script with couple of parameters:
- — channel: decides the branch which you want to install from the dotnet.
- LTS is Long Term Support
- STS is Short Term Support
- — version: can be used to install a specific version of the dotnet core. It is used in replacement to the –channel parameter
- ex: –version 6.0.1
- — install: this helps us to install the dotnet at a specific directory. It’s important to know the directory as it’s required to set the path at the next step.
- The default path is the current directory.
Step 4: Set Environment Path
You need to edit the .profile file in your home directory as it’s the ideal location for environment variables which could be inherited from the login screen. Use the following command to start editing the file:
sudo nano ~/.profile
The add the following 2 lines to the file:
export PATH=$PATH:/etc/dotnet
export DOTNET_ROOT=/etc/dotnet
Save and close the file. You can restart your system at this point if you want to or continue to very the installation.
Step 5: Verify Installation
To verify dotnet installation on any system you can use two commands as follows:
dotnet --version
which typically just shows the active version of dotnet on the system. Although it’s enough to make sure you have a dotnet version installed, if you need more information, you can use the following command:
dotnet --info
The info shows information regarding the active version as well as all versions installed on the system.
Now your system is ready to be used as a development machine or for hosting dotnet core applications. We will dicuss the dotnet hosting in some other article.