Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Instructions on how to get the latest dotnet core 3 (as of 24th April 2019) and Blazor running on a Raspberry PI
*******************************************************************************************************
** PLEASE NOTE THAT THIS IS NOW SOMEWHAT OUT OF DATE, THE GENERAL APT-GET LINUX INSTALL INSTRUCTIONS **
** FOR UBUNTU/DEBIAN NOW LARGLEY WORK ON RASBIAN **
*******************************************************************************************************
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/549f71f9-ba29-476d-8e15-b450f7ba2504/59825a1fcc5aa35344e4f44b2e9f94db/dotnet-sdk-3.0.100-preview4-011223-linux-arm.tar.gz
wget https://download.visualstudio.microsoft.com/download/pr/0c4d44a8-3ccd-45f4-994f-ea93008226eb/c4088c9872670837bb2fa55162fd5c77/aspnetcore-runtime-3.0.0-preview4-19216-03-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-preview4-011223-linux-arm.tar.gz -C /opt/dotnet/
sudo tar -xvf aspnetcore-runtime-3.0.0-preview4-19216-03-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-preview4-19216-03
(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 blazorhosted
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.Server
{
public class Program
{
public static void Main(string[] args)
{
BuildWebHost(args).Run();
}
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseConfiguration(new ConfigurationBuilder()
.AddCommandLine(args)
.Build())
.UseUrls("http://*:5000")
.UseStartup<Startup>()
.Build();
}
}
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.
@Prites

This comment has been minimized.

Copy link

@Prites Prites commented Jun 27, 2019

Wow ...that's great...

@shawty

This comment has been minimized.

Copy link
Owner Author

@shawty shawty commented Jun 27, 2019

Thanks, glad you found it useful.

@shawty

This comment has been minimized.

Copy link
Owner Author

@shawty shawty commented Aug 4, 2019

I've had an email from GitHub with as message in from "Dario" but I can't seem to see his comments on here, so answering the Q I got asked.

Installing preview 7 is more or less the same, just adjust the version numbers where you need too.

@DarioDusper1992

This comment has been minimized.

Copy link

@DarioDusper1992 DarioDusper1992 commented Aug 5, 2019

Hi deleted the post , because I was able to upgrade to priview 7,

Thank you

@shawty

This comment has been minimized.

Copy link
Owner Author

@shawty shawty commented Aug 5, 2019

@dariodusper - ah, I see. No worries. I've not tried (Well not on the rPI) yet. Been busy working on mainstream PC with it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment