ASP.NET Core 3.0 will run on RaspberryPi and other boards out of the box. There are also SDK binaries available in .NET Core 3.0 download page. Having full SDK available on RaspberryPi means that we can now build applications on board. Let’s see how it works.
Previously we were able to build and publish ASP.NET Core applications for Windows 10 IoT Core like described in my blog post Running ASP.NET Core 2 applications on Windows 10 IoT Core.
Installing .NET Core 3.0 on RaspberryPi
I have RaspberryPi 2 with latest Windows 10 IoT Core.
- Download ARM SDK binaries from .NET Core 3.0 download site
- Open RaspberryPi disk in Windows Explorer (\\minwinpc\u$) – you may have one disk (C:) and it’s okay to use it.
- Create folder called dotnet
- Copy files from ARM SDK archive to dotnet folder on RaspberryPi.
Let’s make sure everything works as expected.
- Open Powershell as admin and connect to RaspberryPi
Enter-PSSession -ComputerName minwinpc -Credential minwinpc\Administrator
- Add dotnet folder to path
$Env:Path += ";C:\dotnet\"
- Run dotnet command to see if .NET Core works.
This command gives us some useful information – we get RID to use when building and running application.
If there were no problems or errors we are good to go with developing .NET Core 3.0 applications on RaspberryPi and Windows 10 IoT Core.
Before building web application I have few words to say about development options.
As Windows 10 IoT Core doesn’t have any command-line text or code editor we cannot go with pure command-line ASP.NET Core development. We have to open code folder with Windows Explorer on some other machine and there we can use whatever we like to use for coding. Be it Visual Studio, Visual Studio Code or some other code editor.
We can build application in dev box or on Windows 10 IoT Core. It’s up to us. But we have to run application on Windows 10 IoT Core for sure and for this we have to use Powershell or SSH.
Visual Studio Code Remote
Visual Studio Code has something called Remote. It is set of extensions that allow us to build and run code on remote machine. Currently Windows 10 IoT Core is not supported. I have secret hope that it will happen one day also for Windows 10 IoT Core.
If you are running Linux on RaspberryPi then head over to blog post Visual Studio Code Remote Development over SSH to a Raspberry Pi is butter by Scott Hanselman.
Creating ASP.NET Core application Windows IoT Core
Let’s create default ASP.NET Core application now.
- Create folder for application and move to the folder
- Run dotnet utility to create new web application
dotnet new mvc
- Make sure CreateHostBuilder method looks like shown here
public static IHostBuilder CreateHostBuilder(string args) =>
- Open port 5001 in Windows IoT Core firewall settings by command
netsh advfirewall firewall add rule name="ASP.NET Core" dir=in action=allow protocol=TCP localport=5001
- Build and run application
dotnet build --runtime win10-arm dotnet run --runtime win10-arm
- Open browser and type in the address of web application (http://minwinpc:5001)
Those who want to run web application automatically when Windows 10 IoT Core starts will find useful tips from my blog post Running ASP.NET Core 2 applications on Windows 10 IoT Core.
There’s actually more for ASP.NET Core 3.0 on RaspberryPi – we can also write applications that communicate with hardware. This is separate topic to cover in future blog posts.
ASP.NET Core 3.0 works on RaspberryPi with all command-line tooling. Besides running applications we can also build them now on RaspberryPi. On Windows 10 IoT Core we cannot go with full command-line development but we need some external machine where code editor runs. Those who run Linux on RaspberryPi can go with Visual Studio Code Remote to build and run applications straight on board. Windows 10 IoT Core users have to use mapped network drive and regular tooling. All and all things work nice and new ASP.NET Core puts less load on my old board compared to ASP.NET Core 2.2.
View Comments (4)
So do you use port 5000 or port 5001? It is very confusing to be honest
Sorry, my bad... Port must be 5001. Made updates to post too.
Just a couple of things:
- the command to get the the installed .Net is "dotnet --info" (double dash)
- I wasn't able to PSRemote in the Raspberry Pi (3), I had to follow this guide: https://www.hanselman.com/blog/SettingUpWindows10ForIoTOnYourRaspberryPi2.aspx
Specifically, those commands:
net start WinRM
Set-Item WSMan:\localhost\Client\TrustedHosts -Value MINWINPC
remove-module psreadline -force
Enter-PsSession -ComputerName MINWINPC -Credential MINWINPC\Administrator
Any thoughts on how to setup a net core app to run headless at start up? Every tutorial stops short of adding practical advice.