My question is How can I write the windows service in .net core which we used to write in prior .net versions ?
Lots of links/articles explain how to host your .net
Not sure if there is a default way of doing this. You can however let your core application inherit from ServiceBase and implement the necessary overrides. We do this in our application (note that we target the full framework, not core). The original idea for this came from the following articles:
Note that these articles still reference DNX (from the .NET Core beta days) - these days your core app will compile to an exe, so you can adjust their examples to cater for that.