Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make .net core console app a single .exe

Tags:

c#

.net-core

I have a C# .NET Core 2.0 console app. I want to deploy it so it is a single .exe file with all associated .dll included in the .exe.

Is this possible?

The reason I want to do this is I have made several console apps and I want to put them in the same folder so that only 1 path entry is required to make them available from the command line.

If I publish with dotnet publish -c Release -r win10-x64 I get an .exe but I also get a load of other files.

Is there anyway to either move all these associated files to a named subfolder or to wrap them all up in a single file?

like image 861
Guerrilla Avatar asked Apr 22 '18 15:04

Guerrilla


People also ask

How do you make an exe file standalone?

If you want to make a standalone program, you should create a new Setup project in your solution. Include the Primary Output from your application project, and the setup should include the required DLL's automatically. Once you build the setup project, you can install your application as a standalone software.


2 Answers

No, right now .NET Core does not support producing a single .exe that contains your entire application.

And don't be confused when you read about self-contained apps. Self-contained means that application is published for a specific OS by specifying the target runtime (like -r win10-x64) and this allows not to have the .NET Core as the shared runtime in the target machines.

like image 181
Set Avatar answered Sep 28 '22 13:09

Set


I know this question is a few years old but now finally, this is possible with .NET Core.

You can achieve this in two different ways

  1. In a console/terminal
dotnet publish -r win-x64 -c Release /p:PublishSingleFile=true
  1. Publish the application

enter image description here

enter image description here

enter image description here

You can find more info from the links below

https://docs.microsoft.com/en-us/dotnet/core/deploying/single-file

https://dotnetcoretutorials.com/2019/06/20/publishing-a-single-exe-file-in-net-core-3-0/

like image 31
Pissu Pusa Avatar answered Sep 28 '22 14:09

Pissu Pusa