Reputation: 49
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?
Upvotes: 4
Views: 4395
Reputation: 6509
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
dotnet publish -c Release -r win10-x64 --self-contained true
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
Upvotes: 1
Reputation: 4824
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
Upvotes: 2
Reputation: 61636
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
Upvotes: 1
Reputation: 276
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:
Upvotes: 1