How to Create a .NET Core CLI Console App as an EXE Instead of a DLL

You may have just discovered that when you create a console app using the .NET Core CLI tools it only produces a DLL by default.

If you execute this:

dotnet new console -n App

And then execute a build

dotnet build

You will get this output:

It took me a while to figure this out, but in order to generate an EXE instead of a DLL, you need to pass a ‘runtime’ to the build command, like this:

dotnet build -r win10-x64

Which will produce an EXE:

List of valid runtimes (RIDs) can be found here: https://docs.microsoft.com/en-us/dotnet/core/rid-catalog#using-rids

Jon