You can find all .Net core posts here.
In this quick post, we will see how to create an exe from .Net Core console application.
Little background
When we create a console application using .Net Core, you will notice that the exe would not be created when you build the application.
Let us quickly create an application to check this.
I created a .Net Core console application and built the solution. If we open the debug folder, we can see everything except the exe:
Do not think it is a bug in .Net Core, but actually it is a feature. the dlls generated is nothing but the portable apps model which does not generate the exe. They are executed by the .Net Core shared run-time. You can just run the application by running the command dotnet run.
You can read nice explanation here: https://stackoverflow.com/questions/44038847/vs2017-compile-netcoreapp-as-exe
Generate the exe
But, If you really want to generate the exe then just run below command:
dotnet publish -c Debug -r win10-x64
Update: As per the comment below from Stig Schmidt Nielsson:
Fine tip, but one should consider to do a release or debug build. For release builds:
dotnet publish -c Release -r win10-x64
This command will generate the exe as you can see below:
This will create the stand alone apps which are similar to our old .Net applications. This allows not to have the .NET Core as the shared run-time in the target machines.
You can find valid run-time from here: https://docs.microsoft.com/en-us/dotnet/core/rid-catalog#rid-graph
Hope it helps.
Fine tip, but one should consider to do a release or debug build. For release builds:
dotnet publish -c Release -r win10-x64
LikeLike
Hey. Yes right. I will update my post with this comment. Thanks.
LikeLike
What about making it generate one single .exe and not have any other files?
LikeLike
Hello Chris, this thread should help you: https://stackoverflow.com/questions/49967697/make-net-core-console-app-a-single-exe
LikeLike