Writing worker service on Windows and deploying on Linux

Frank Martin 456 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?

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,643 questions
.NET Runtime
.NET Runtime
.NET: Microsoft Technologies based on the .NET software framework.Runtime: An environment required to run apps that aren't compiled to machine language.
1,141 questions
0 comments No comments
{count} votes

Accepted answer
  1. Bruce (SqlWork.com) 61,491 Reputation points
    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