3

Is there a possibility to publish .NET Core Console Application as single file (no matter if it's EXE or DLL)?

I am using .NET Core 1.1 but I am elastic to port my project to another version.

mankers
  • 742
  • 10
  • 19
  • You should be able to do something with satellite assemblies – realbart Jun 01 '17 at 08:17
  • Take a look at https://stackoverflow.com/questions/37390798/build-exe-file-in-net-core-rc2?rq=1 – realbart Jun 01 '17 at 08:24
  • I tried to follow instructions from answer you linked, but no effects. After publish I get very long list of DLL's (not only one). – mankers Jun 01 '17 at 09:01
  • @mankers What is meant by "elastic?" Do you mean you are hoping or planning to port your project to another version? – Anthony Gatlin Jun 05 '17 at 06:42
  • @AnthonyGatlin Not exactly, I am launching new project and it's currently at research stage. – mankers Jun 05 '17 at 06:47
  • @mankers What is meant by the word "elastic" in your question? – Anthony Gatlin Jun 05 '17 at 11:57
  • @AnthonyGatlin Elastic, flexible, changeable. I was looking for solution applicable to .NET Core 1.1. However, if you gave me a ready solution working on .NET Core 2.0, I would consider porting my project (with very tiny SLoC) to .NET Core 2.0. It's gonna be very simple app and the only requirement is to be written it in .NET Core *.*. – mankers Jun 06 '17 at 10:11
  • @mankers I don't believe there are going to be many breaking changes in .NET Core 2.0. I am still working on .NET Core 1.1, but my understanding is that it is pretty much backwards compatible. CoreRT is what I think you are looking for to get a single executable file as Martin Ullrich had suggested. https://github.com/dotnet/corert – Anthony Gatlin Jun 06 '17 at 15:02

1 Answers1

8

At the moment, this is not possible because:

  • portable applications still need at least a runtimeconfig.json to tell the host (dotnet / dotnet.exe) which shared runtime to use. Even if you IL-Merge all your managed code into a single dll, this file is still required. The host also expects a deps.json expressing the dependencies of the application.
  • self-contained applications rely on building a .dll + .deps.json and copying over content from runtime-specific NuGet packages. This also includes native libraries that are searched for by file name.

The CoreRT project aims to compile a .NET Core application to a single native binary using ahead-of-time compilation but is still in development.

Martin Ullrich
  • 94,744
  • 25
  • 252
  • 217