X

Installing ASP.NET Core 3.0 on RaspberryPi and Windows 10 IoT Core

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.

  1. Download ARM SDK binaries from .NET Core 3.0 download site
  2. Open RaspberryPi disk in Windows Explorer (\\minwinpc\u$) – you may have one disk (C:) and it’s okay to use it.
  3. Create folder called dotnet
  4. Copy files from ARM SDK archive to dotnet folder on RaspberryPi.

Let’s make sure everything works as expected.

  1. Open Powershell as admin and connect to RaspberryPi
    Enter-PSSession -ComputerName minwinpc -Credential minwinpc\Administrator
  2. Add dotnet folder to path
    $Env:Path += ";C:\dotnet\"
  3. Run dotnet command to see if .NET Core works.
    dotnet –info

    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.

Development options

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.

  1. Create folder for application and move to the folder
    mkdir webapp
    cd webapp
  2. Run dotnet utility to create new web application
    dotnet new mvc
  3. Make sure CreateHostBuilder method looks like shown here
    public static IHostBuilder CreateHostBuilder(string[] args) =>
        Host.CreateDefaultBuilder(args)
            .ConfigureWebHostDefaults(webBuilder =>
            {
                webBuilder.UseStartup<Startup>();
                webBuilder.UseUrls("http://*:5001/");
            });
  4. 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
  5. Build and run application
    dotnet build --runtime win10-arm
    dotnet run --runtime win10-arm
  6. 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.

Wrapping up

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.

Liked this post? Empower your friends by sharing it!

View Comments (4)

Related Post