Michael Hedgpeth
Michael Hedgpeth

Reputation: 7862

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.

Upvotes: 12

Views: 5636

Answers (2)

Lee Richardson
Lee Richardson

Reputation: 8827

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

Upvotes: 5

J. Doe
J. Doe

Reputation: 2747

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.

Upvotes: 7

Related Questions