This sample shows how to create a Windows Service that runs a Kestrel server. Further documentation is here.
This sample requires dependency from Microsoft.Extensions.Hosting.WindowsServices.
Run Visual Studio Command Line under administrator mode.
Run the following command sc create "{Fill Service Name} binpath="{Full path to your Windows Service EXE}"
Open Windows Services Manager and start the service.
or you can execute this command sc start "{Fill Service Name}"
to start the service from the VS Command Line.
To stop the service, execute this command sc stop "{Fill Service Name}"
.
Run Visual Studio Command Line under administrator mode.
Run the following command sc delete "{Fill Service Name}"
.
dotnet6