I am currently using Visual Studio for Mac and I need to create a background running service application. I realised that the only option that I have is the Console Application in VS Mac. The exe that I will create should run as a Windows Service when deployed to a Windows server or a daemon process in a Linux server.
Can achieve this with Net Core? Is it possible to create a cross platform service process with Visual Studio for Mac?
Yes, you can. With .Net Core 3.1, you can create a project using the "Worker Service" template. Then install the Microsoft.Extensions.Hosting.WindowsService NuGet package and add UseWindowsService()
to the CreateHostBuilder
method.
You can see a more detailed answer in this post: Building a Windows service with Worker Services and .NET Core 3.1, part 1: Introduction