Issue
My question is what it says in the title. I want to build my C# application into executables for Windows, Linux and MacOS, such that I can put them in a release on my github repo. How do I do that? Maybe a makefile or something like that to create all at once would be handy?
Solution
If you are using .NET Core 3.x or later, you can use dotnet publish
with various options to produce stand-alone executables:
dotnet publish -c Release -r linux-x64 -p:PublishSingleFile=true
You will need to re-run this command for each platform (Windows, macOS, Linux) that you want to target:
dotnet publish -c Release -r win-x64 -p:PublishSingleFile=true
dotnet publish -c Release -r osx-x64 -p:PublishSingleFile=true
-p:PublishSingleFile=true
produces a single executable that you can copy around and run. You can attach it as an artifact with the release on GitHub.
(Aside: This executable will automatically extract itself into a few dozen files and then run that version. That means that you wont be able to run it, for example, on a system without a disk that you can write to.)
And yes, you can definitely wrap this up in a Makefile
or something. Here's an example from a cli tool that I work on:
publish:
dotnet publish \
-c $(CONFIGURATION) \
-r $(RUNTIME) \
-p:PublishSingleFile=true
Answered By - omajid Answer Checked By - Mary Flores (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.