Installing ASP.NET Core 3.0 on RaspberryPi and Windows 10 IoT Core
Get ASP.NET 3.0 Core on your RaspberryPi.
Join the DZone community and get the full member experience.
Join For FreeASP.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 a full SDK available on RaspberryPi means that we can now build applications on board. Let’s see how it works.
Installing .NET Core 3.0 on a RaspberryPi
For this tutorial, I'm going to use a RaspberryPi 2 with the latest Windows 10 IoT Core. In order to download .NET Core 3.0, follow these next steps:
- Download ARM SDK binaries from .NET Core 3.0 download site.
- Open the RaspberryPi disk in Windows Explorer (\\minwinpc\u$) — you may have one disk (C:). That’s okay to use.
- Create a folder called, "dotnet."
- Copy the files from the ARM SDK archive to the dotnet folder on the 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 the dotnet folder to the path.
$Env:Path += ";C:\dotnet\"
- Run the following dotnet command to see if .NET Core works.
dotnet –info
If there were no problems or errors, we are good to continue with developing .NET Core 3.0 applications on RaspberryPi and Windows 10 IoT Core.
Development Options
Before building the web application, I have a few words to say about development options.
As Windows 10 IoT Core doesn’t have a command line text or code editor, we cannot go with pure command line ASP.NET Core development. We have to open the code folder with Windows Explorer on some other machine. From 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 an application in a dev box or on Windows 10 IoT Core. It’s up to us, but we have to run the application on Windows 10 IoT Core for sure. For this, we have to use Powershell or SSH.
Visual Studio Code Remote
Visual Studio Code has something called Remote. It is a set of extensions that allows us to build and run code on a remote machine. Currently, Windows 10 IoT Core is not supported. I have a 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 a default ASP.NET Core application now.
- Create a folder for an application and move to the folder
mkdir webappcd webapp
- Run dotnet utility to create a new web application
dotnet new mvc
- Make sure CreateHostBuilder method looks like this:
public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); webBuilder.UseUrls("http://*:5001/"); });
- Open port 5000 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 the application
dotnet build --runtime win10-arm dotnet run --runtime win10-arm
- Open the browser and type in the address of web application (http://minwinpc:5000).
ASP.NET Core 3.0 on RaspberryPi
There’s actually more for ASP.NET Core 3.0 on RaspberryPi — we can also write applications that communicate with hardware. This is a separate topic to cover in future blog posts.
Wrapping Up
ASP.NET Core 3.0 works on RaspberryPi with all command line tooling. Besides running applications, we can also build them on a RaspberryPi. On Windows 10 IoT Core, we cannot perform full command line development; rather, we need some external machine where a code editor can run. 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.
Published at DZone with permission of Gunnar Peipman, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments