mankers
mankers

Reputation: 752

Publish ONE executable file

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.

Upvotes: 3

Views: 1240

Answers (2)

Chris Collett
Chris Collett

Reputation: 1279

You can use a post-release process to wrap up the release into a self executing archive (such as PyInstaller or IExpress).

The archive includes all your release files, and can be configured to launch a specific application file after extraction.

This would be a good fit for installers, where you want to only provide a single file but don't want a bootstrapped installer.

Caveats:

  • By default, most self extracting archives will extract to a temporary directory, and clean up (i.e., delete) the directory after the application terminates.
  • Start up times will, naturally, be slower due to the extraction process - larger release, longer extraction time.
  • OS specific self extracting archives may be required for cross-platform compatibility.

Upvotes: 0

Martin Ullrich
Martin Ullrich

Reputation: 100581

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.

Upvotes: 8

Related Questions