you have two options.
create a standard asp.net core website and run the command line with srvany.exe
https://learn.microsoft.com/en-us/troubleshoot/windows-client/deployment/create-user-defined-service
create a asp.net core service that support asp.net core: