question

FrankMartin-0949 avatar image
0 Votes"
FrankMartin-0949 asked Bruce-SqlWork answered

Writing worker service on Windows and deploying on Linux

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?

dotnet-runtimedotnet-ad
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Bruce-SqlWork avatar image
0 Votes"
Bruce-SqlWork answered

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


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.