Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why when compiling .NET Core console application we end up with both dll and exe files?

I have noticed that both dll and exe files with the name of the project are created on Windows when compiling a .NET Core console application. Why is that? In full .Net framework only the exe file would be created.

like image 272
mark Avatar asked Apr 09 '20 00:04

mark


People also ask

What is the difference between the DLL and the EXE in .NET framework?

Difference between exe and dll-1. EXE is an extension used for executable files while DLL is the extension for a dynamic link library. 2.An EXE file can be run independently while a DLL is used by other applications. 3.An EXE file defines an entry point while a DLL does not.

How to create exe for NET Core console application?

How To Create EXE For .Net Core Console Application 1 Create a .NET Core Console application and click on the OK button. ... 2 Build the solution and open the corresponding folder just like in the below image. ... 3 Open your command prompt and go to that folder where your application persists. ... More items...

What is the difference between DLL and Exe in NET Framework?

DLL (Dynamic Link Library) In .NET Framework when we compile a Console Application or a Windows Application, it generates EXE, whereas when we compile a Class Library Project or ASP.NET web application, then it generates DLL. In.NET framework, both EXE and DLL are called assemblies. Understanding DLL and EXE in .NET Framework:

How do I generate 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. 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: Which will produce an EXE:

What is a DLL executable?

This executable simply runs your application which is stored inside the DLL file (the DLL file may be executed directly via dotnet full_generated_dll_path ). I guess .exe output is convenient in services / daemon scenarios. The project usually has some dependencies (both managed and unmanaged), so the output contains a lot of DLL files.


Video Answer


1 Answers

Prior to .Net Core 3.0, only the dll was created (although you could still do a single file build that was platform-dependent). In these cases you had to use the command dotnet MyProject.dll to start your program.

With .Net Core 3.0, they added the exe, which is still really just a wrapper around the command above. On other operating systems it also creates an executable file, it just names it MyProject instead of MyProject.exe

If people have old scripts that still make the dotnet command, this setup doesn't break them, but if you want to just use an exe, you can do that too.

like image 168
pquest Avatar answered Oct 23 '22 20:10

pquest