Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a dotnet core single executable

I would like to configure my dotnet core project to compile as a single executable.

The project is similar to the one generated with dotnet new:

{
  "version": "1.0.0-*",
  "buildOptions": {
    "debugType": "portable",
    "emitEntryPoint": true
  },
  "dependencies": {},
  "frameworks": {
    "netcoreapp1.1": {
      "dependencies": {
        "Microsoft.NETCore.App": {
          "version": "1.1.0"
        }
      },
      "imports": "dnxcore50"
    }
  },
  "runtimes": {
     "win10-x64": {}
   }
}

How can I make it so this compiles as a single program.exe? When I run dotnet publish it puts dlls and the program.exe in a publish folder, but doesn't combine them.

like image 577
Michael Hedgpeth Avatar asked Dec 14 '16 22:12

Michael Hedgpeth


People also ask

Can mono run .NET Core?

NET Core, which natively only allows you to build console apps and web applications, mono allows you to build many application types available in . NET Framework, including GUI-enabled desktop apps. So, if mono can do everything that . NET Core can while .


2 Answers

This is available as of .Net Core 3 like:

dotnet publish -r win10-x64 -p:PublishSingleFile=true

See also https://learn.microsoft.com/en-us/dotnet/core/whats-new/dotnet-core-3-0#single-file-executables

like image 81
Lee Richardson Avatar answered Oct 24 '22 11:10

Lee Richardson


The closest to answer is probably CoreRT (.Net Core to Native). It will be excellent fit but exist small problem - This project is still in early apha. A year ago they showed us demo but it was a very simple example and for more advanced projects will not work. Some more information how to try do this.

like image 7
J. Doe Avatar answered Oct 24 '22 10:10

J. Doe