Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a self-contained executable for a .NET Core Console application? [closed]

I want to create a self-contained executable for my .NET Core Console application that can be run on the command line without the dotnet command. When I try to create a self contained executable using dotnet publish -r osx-x64, a .dll with the project name is created in the output folder, e.g. myproject.dll, instead of an EXE file (I'm assuming on MacOS self contained applications are EXE files just like on Windows). I cannot run myproject.dll directly without using the dotnet command, I have to run dotnet myproject.dll arg1 in order for the program to execute.

like image 761
bit Avatar asked Nov 01 '25 20:11

bit


2 Answers

Adding on to @MyWrathAcademia's answer...

A self contained application does not require the .NET Runtime on the target system, and bundles it's own .NET Runtime. A runtime dependent application depends on the .NET Runtime on the target system, so it has to be executed using "dotnet run".

See here for more information.

like image 79
rohan Avatar answered Nov 03 '25 11:11

rohan


The executable file is in the publish folder. In Windows executables have a .exe file extension where as on Linux and OSX (i.e. MacOS) executables do not have file extensions.

like image 33
bit Avatar answered Nov 03 '25 10:11

bit