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
1. Create startup.ps1#
Create startup.ps1 with the following contents
1Set-Location C:\publish\ 2.\aspnet.on.rpi.exe
2. Create startup.bat#
Create startup.bat with the following contents
1powershell -command "C:\startup.ps1"
3. Copy the files to your Raspberry#
Connect to Raspberry using powershell, start the ftp server
1Enter-PSSession -ComputerName <Raspberry IP> -Credential <Raspberry IP>\Administrator 2start C:\Windows\System32\ftpd.exe
Open the File Explorer ftp://<TARGET_DEVICE> and copy both startup.ps1 and startup.cmd to your Raspberry
4. Schedule the command to run on Startup#
Connect to Raspberry using powershell and run
1Enter-PSSession -ComputerName <Raspberry IP> -Credential <Raspberry IP>\Administrator 2schtasks /create /tn "Startup Web" /tr c:\Startup.bat /sc onstart /ru SYSTEM
5. Restart and verify#
Restart your Raspberry and after a bit your ASP.NET Core app should be up and running.
Hope it helps!