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?
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.
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.
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
dotnet publish -r win-x64 -c Release /p:PublishSingleFile=true
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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With