How to set Asp.Net Core app as a service in Windows 10 IoT Core?

1k views Asked by At

I have successfully deployed an ASP.NET Core 2.0 (MVC) on Win IoT Core (running on Rasp Pi 3). The device is listening on 192.168.0.14:80.

enter image description here

I activate the application via PowerShell (from my host computer connected to the device) as follows.

enter image description here

The problem is that if I close the PowerShell window, the server stop listening.

Question

How to active the web application as a service that is always running even after restarting the device?

1

There are 1 answers

2
Carlos Mendible On BEST ANSWER

You should try connectin to the RPi:

Enter-PSSession -ComputerName <Raspberry IP> -Credential <Raspberry IP>\Administrator

And then schedule a task:

schtasks /create /tn "Startup Web" /tr c:\Startup.bat /sc onstart /ru SYSTEM

Where startup.bat executes a powershell script with something like:

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

Check this post for a complete sample: https://carlos.mendible.com/2017/03/26/raspberry-pi-run-aspnet-core-on-startup/