Sunday, 1 March 2020

.NET Core development on a Raspberry Pi 4


These are start-to-finish instructions for creating and operating a Blazor application on a Raspberry Pi 4.  I have the 4GB model, but that is not too relevant - any memory size should be fine.

You will need

  • A Raspberry Pi 4
  • An SDXC card (I'm using 64GB, but 16GB or more should be fine)
  • A laptop (instructions here are for a Windows 10 Laptop)
  • An Internet connection

Install the operating system

  1. Download the following:
    1. Raspbian from here:
    2. BalenaEtcher from here:
  2. Run BalenaEtcher and select the .IMG or .ZIP file to install.

Connecting the hardware


  • A USB keyboard
  • A USB mouse
  • HDMI cable to your TV/Monitor (you will need a special cable for this)
  • Insert the SDXC card into the Pi.  The slot is on the opposite side and at the opposite end of the board to the USB connectors
  • A USB-C power supply


When the Raspberry Pi has power connected, you should see the system "booting" on the TV/monitor.

Security configuration

The first thing you should do on any new installation is to change the default security settings.  The default username/password is pi/raspberry.  You should change this and note that somewhere safe.  

passwd pi

Enter the new password when prompted.

You should also add your own user.  I did this with:

sudo adduser

(this makes you add some details - provide these)

If the user is a system administrator (you will be, other family members may not be!)  run the same command with sudo on the end:

sudo adduser sudo

Now add users for other family members using the same commands.

You may wish to set up private and public keys, thought that is beyond the scope of this article.

Setting up SSH

Once the boot is complete, you may wish to add SSH access so that you can use your regular PC/laptop screen and keyboard, instead of always having the Raspberry Pi connected to the TV/monitor.

To enable SSH, follow instructions here:
Once you have added SSH access, we will set the IP address to a static one.  Before you do this, check your router for an IP address NOT in the DCHP range.  For example, if your router uses the range, you might (like me) choose to use  To double check that nothing else is using it, ping it:


Remember, you DON'T want anything to respond on that address.  If there is no response, you should see a number of messages containing "Destination host unreachable".

To set up the Pi to use your selected address, edit the file /etc/dchpcd.conf and uncommenting and editing the lines that look like this:

# Example static IP configuration:
interface wlan0
static ip_address=
#static ip6_address=fd51:42f8:caae:d92e::ff/64
static routers=
static domain_name_servers=

You can leave the IPv6 line commented out with the # symbol.

In this example, my private subnet is, my gateway (which also serves as a DNS server) is on, I am allocating a static IP address of and I am using Google ( as a backup DNS server.

Set up Remote Desktop access

You may be fortunate enough to have a spare TV hanging around, in which case you can carry on all remaining steps using that.  If someone else wants to use the TV, you can do the rest from your laptop.  To do so, you will need to enable the Remote Desktop Protocol, by installing xrdp.
This website explains how to do this:
However, it just comes down to running the following command:

sudo apt-get install xrdp

Once this is done, you can use your Windows 10 laptop and run "Remote Desktop Connection" and connect to the static IP address you chose earlier.  Remember, you changed the default

Setting up the development environment

As we will be programming in C#, we will need .NET Core for ARM32 (the Raspberry Pi's processor) and an IDE (we will be using Visual Studio Code).

Install .NET Core

Firstly, go get the ARM32 files for .NET Core.  At the time of writing, the lastest version is 3.1.102, and the files are available here:
...however, you should install the latest version.

The easiest way to do that is to determine the correct URLs from the page above, then execute command like the following:
      You can then install them as follows (check version numbers match what you have downloaded):

      mkdir dotnet-arm32
      tar zxf dotnet-sdk-3.1.102-linux-arm.tar.gz -C dotnet-arm32
      tar zxf aspnetcore-runtime-3.1.2-linux-arm.tar.gz -C dotnet-arm32

      Note that this results in the SDK and ASP.NET Core runtimes being available for you only, not other users.

      Install Visual Studio Code

      Headmelted provides a version of Visual Studio code for the Raspberry Pi.

      Check the contents of, then run the following:

      . <( wget -O - )

      Once complete, you should be able to run Code using:


      No comments:

      Post a Comment