Raspberry Pi: Run ASP.NET Core on Startup

Raspberry Pi: Run ASP.NET Core on Startup

Last week I wrote: Step by step: Running ASP.NET Core on Raspberry Pi and didn’t have the time to write about running the application on startup.

After browsing for a while I found this great post: Windows IoT Core: Running a PowerShell Script on Startup which showed me the way!

As a prerequisite read and run the sample provided here: Step by step: Running ASP.NET Core on Raspberry Pi

Let’s start:

Create startup.ps1


Create startup.ps1 with the following contents

Set-Location C:\publish\
.\aspnet.on.rpi.exe

Create startup.bat


Create startup.bat with the following contents

powershell -command "C:\startup.ps1"

Copy the files to your Raspberry


Connect to Raspberry using powershell, start the ftp server

Enter-PSSession -ComputerName <Raspberry IP> -Credential <Raspberry IP>\Administrator
start C:\Windows\System32\ftpd.exe

Open the File Explorer ftp://<TARGET_DEVICE> and copy both startup.ps1 and startup.cmd to your Raspberry

Schedule the command to run on Startup


Connect to Raspberry using powershell and run

Enter-PSSession -ComputerName <Raspberry IP> -Credential <Raspberry IP>\Administrator
schtasks /create /tn "Startup Web" /tr c:\Startup.bat /sc onstart /ru SYSTEM

Restart and verify


Restart your Raspberry and after a bit your ASP.NET Core app should be up and running.

Get the code here: https://github.com/cmendible/dotnetcore.samples/tree/main/aspnet.on.rpi.startup

Hope it helps!

Last modified December 25, 2024: AKS Static Egress Gateway post (f57758f)