I'd imagine this as a massively dumb question but when I build my solution (console app) it creates a dll rather than an executable. Am I doing something wrong or just misunderstanding how this works?
-
1Is it a .NET Core project? – Broots Waymb Feb 24 '20 at 18:42
-
I think it is (I'm pretty new to VS) – smeel Feb 24 '20 at 18:43
-
Check [this post](https://stackoverflow.com/questions/41705465/build-net-core-as-an-exe-not-a-dll) out. I'm sort of hesitant to flag it as a direct duplicate, but at the very least it's related. – Broots Waymb Feb 24 '20 at 18:46
-
5Don't guess, look at the application type in the property page of your project in Visual Studio. – Dour High Arch Feb 24 '20 at 18:47
-
Please, show a console app project properties, or property group from `cspoj` file – Pavel Anikhouski Feb 24 '20 at 19:38
4 Answers
Right-click on your project in Solution Explorer and select Properties
in the bottom of Context Menu. Select proper Output type
then as marked on the screendhot.
As mentioned in another answer here: in case your Target framework is .NET Core
, use Publish
in the Build
menu of Visual Studio width setting Target runtime
format, for example win-x86
to make a proper output application format.
Check out the reference: Publish your .NET Core application with Visual Studio

- 4,558
- 2
- 12
- 24
-
This assumes that OP's project is framework rather than core. You might want to at least mention that this is a fix for framework. – Code Stranger Feb 24 '20 at 18:49
-
1It would probably be a little more helpful to say something like "Right-click on your project in Solution Explorer" instead of saying "ConsoleApp1". That might not be the name of OP's project. Also, typo on "screenshot". – Broots Waymb Feb 24 '20 at 18:50
-
If this is .Net Framework then more than likely the project output type is set to Class Library in the project properties page.
To fix this you must ensure that you have a method with a signature of static void Main()
and set the Output type to Console Application.
To Change the Output Type:
- Right click the Project name in the Solution Explorer
- Select Properties
- On the Application tab change Output Type to Console Application
- Change the Startup object drop down to the class that contains your Main method.
- Save the Properties and try to build/debug again.

- 216
- 3
- 3
-
-
@smeel - verify whether your project is framework or core. If it's core then this isn't going to address your issue. – Code Stranger Feb 24 '20 at 18:53
No, that's legit. At least for .NET Core 2.x. For .NET Core 3.x, it does build an .EXE. You could always run it by running: dotnet foo.dll
.
So for now, instead of Build, use Publish. That will generate an .EXE.
I typically keep a command handy to just generate it quickly:
dotnet publish -c Release -r win10-x64 --self-contained:false

- 59,598
- 102
- 325
- 594
-
-
@smeel Open Command Prompt in the same directory as your .csproj file. Then just run this. – AngryHacker Feb 25 '20 at 18:32
Publishing to exe from Visual Studio
Right Click Project > Publish > Configure
Select
Deployment Mode: Self-Contained
Select
Preferred Target Runtime
Note down the Target location
Hit Publish
You will now find your exe in the target location that you made note of
Note: The default option is set to Framework dependant mode, which is why you see the dll file as the output and to run that you can dotnet MyConsoleApp.dll
.NetCore 2.1 / 2.2 / 3.0 (Via Command Line)
-
dotnet publish -c Release -r win10-x64 --self-contained true
.NetCore 3.0 (Via Command Line)
Publish SelfContained SingleFile App:
dotnet publish -r win10-x64 -c Release /p:PublishSingleFile=true
Publish Trimmed Self Contained App:
.CSProj
<PropertyGroup> <PublishTrimmed>true</PublishTrimmed> </PropertyGroup>
dotnet publish -c Release -r win10-x64 --self-contained true

- 6,011
- 1
- 21
- 28