Forked from shawty/rpi_install_instructions.txt
Last active
January 14, 2021 21:39
-
-
Save pjgpetecodes/8337e903f6b458f9bb6cf7c204dcdb3e to your computer and use it in GitHub Desktop.
Instructions on how to get the latest dotnet core 3 and Blazor running on a Raspberry PI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is a fork of Shawty's original instructions simply updated to use the release version of Dot Net Core. | |
First things first, make sure your Raspberry PI has the latest updates for Raspbian on by running | |
sudo apt-get -y update | |
sudo apt-get -y upgrade | |
Also make sure that your running this on a version 2 raspberry PI or higher (I tested this on a Quad Core V3 B+, and a V2 PI Zero) | |
This will NOT WORK on any PI model that's older, I tried it on an original V1 and to say it wasn't happy, was an understatement :-) | |
Right, prerequisates: | |
From the command line run | |
sudo apt-get -y install libunwind8 gettext | |
Then in your home directory ("/home/pi" if your using the default) run the following to download the binaries | |
wget https://download.visualstudio.microsoft.com/download/pr/8ddb8193-f88c-4c4b-82a3-39fcced27e91/b8e0b9bf4cf77dff09ff86cc1a73960b/dotnet-sdk-3.0.100-linux-arm.tar.gz | |
wget https://download.visualstudio.microsoft.com/download/pr/e9d4b012-a877-443c-8344-72ef910c86dd/b5e729b532d7b3b5488c97764bd0fb8e/aspnetcore-runtime-3.0.0-linux-arm.tar.gz | |
Once the tar.gz files finish downloading, run the following commands at your command line while still in your home directory | |
sudo mkdir /opt/dotnet | |
sudo tar -xvf dotnet-sdk-3.0.100-linux-arm.tar.gz -C /opt/dotnet/ | |
sudo tar -xvf aspnetcore-runtime-3.0.0-linux-arm.tar.gz -C /opt/dotnet/ | |
sudo ln -s /opt/dotnet/dotnet /usr/local/bin | |
If all goes ok, you should be able to run | |
dotnet --info | |
And see your dotnet command list it's details | |
Next you need to install the blazor templates | |
dotnet new -i Microsoft.AspNetCore.Blazor.Templates::3.0.0-preview9.19465.2 | |
(Thanks to Magoo for pointing that one out ;-) ) | |
If everything works ok so far, then you have one more step, and this is very important, type | |
export DOTNET_ROOT=/opt/dotnet | |
at the command line to tell the OS where the libs for dotnet etc are. | |
You WILL NEED to run this everytime you sign in to your PI, so find the file named ".bashrc" in your home directory and | |
add that export command as the very last line in the file, that will cause it to be set everytime you login. | |
NOTE: The .bashrc file will need to be edited for every user you expect to sign in and use dotnet on the device | |
Once that's done, create a folder EG: | |
mkdir rpiblazor | |
cd rpiblazor | |
then run | |
dotnet new blazorserver | |
You will also likley need to add a line to Program.cs in the server project to make it listen on all IP addresses | |
assuming your accessing from a browser on a different machine. | |
A suitable program.cs will look something like this: | |
namespace rpiblazor | |
{ | |
public class Program | |
{ | |
public static void Main(string[] args) | |
{ | |
CreateHostBuilder(args).Build().Run(); | |
} | |
public static IHostBuilder CreateHostBuilder(string[] args) => | |
Host.CreateDefaultBuilder(args) | |
.ConfigureWebHostDefaults(webBuilder => | |
{ | |
webBuilder.UseStartup<Startup>(); | |
webBuilder.UseUrls("http://*:5000"); | |
}); | |
} | |
} | |
NOTE the "UseUrls" line and how it uses a * rather than an IP or 'localhost' | |
Then it's just the usual dotnet build/run etc | |
It's not a speed demon to build by the way, I've seen it take 2 mins plus, but once running it's pretty good. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice one!