Home > Back-end >  C# .NET 6.0 - exe only?
C# .NET 6.0 - exe only?

Time:12-21

Hey I switched from NET Framework 4.8 to .NET 6.0

When I build my file it outputs the build.exe (130kb) and an build.dll (2.3mb). So it looks like the exe is using the dll to run as the dll has the source code inside and the .exe doesn't.

Is it possible to build an .exe only without the dll? I tried to use a Costura Fody an resource embedder but that didn't work.

Edit: I was able to use the "publish" feature to create a self contained exe but the file size increased from 3mb to an 180mb exe... Is there any other method?

CodePudding user response:

You probably want a single file framework dependent deployment and not "self contained". This way you would not have to include all the framework file in your deployment package, instead the computer would have to have the framework already installed. To do this, change deployment mode in the deployment settings from self contained to framework dependent. See Single file deployment

You might also check out "trimming" to remove unneeded dependencies, since this should significantly reduce the size of a self contained application.

CodePudding user response:

Your observation is right.

The .exe file of a .NET core app is only a stub loader. The actual code is in the .dll file. For the application project, you now have both an application.dll and an application.exe.

Unless you use any of the options you mentioned (deploy as single file), I don't think there's a way around this.

  • Related