I’ll summarise some options:
- Move your code into a .NET Standard library, and host it in a .NET Framework app, so you can use
ServiceBase
. This will of course need the .NET Framework to be installed on the target machine - Use NSSM (the Non-Sucking Service Manager) to manage a .NET Core console app (it has a public domain license)
- Use Windows API calls to hook into Windows service methods. This is the approach taken by DotNetCore.WindowsService and dotnet-win32-service (both are MIT licensed)