Writing worker service on Windows and deploying on Linux

Frank Martin 501 Reputation points
2022-05-07T18:05:38.017+00:00

Is it possible to write worker service using .net core on Windows and then generate executable file that can be deployed on Linux? So basically that worker service will run under systemd on Linux. What I am mainly confused about is the .exe part which is generated on Windows so how will we able to deploy in on Linux?

Developer technologies .NET .NET Runtime
Developer technologies .NET Other
0 comments No comments
{count} votes

Accepted answer
  1. Bruce (SqlWork.com) 77,686 Reputation points Volunteer Moderator
    2022-05-07T21:39:39.127+00:00

    The dll will run on any system via the dotnet utility. But a publish will create a small o/s dependent app to load and run the dll. Just create Linux publish, and there will be Linux app (MacOS and Linux apps do not have a file extension, just the execute bit set in the directory).

    A Linux daemon is supposed to fork at startup and respond to signals. Microsoft has a nuget package for creating a daemon hosted by launchd. See this article

    https://blog.maartenballiauw.be/post/2021/05/25/running-a-net-application-as-a-service-on-linux-with-systemd.html

    And with .net 6 min api

    https://stackoverflow.com/questions/71233335/use-systemd-on-asp-net-core-6-0

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.