DaveA
DaveA

Reputation: 43

Visual Studio 2019/.NET 5: Compiling Single Project with No Dependencies Creates Application DLL

I moved from from VS15 to VS19 with a new laptop, and my new project is a single Windows Forms project that will go on the client's server to pull metrics, stats, and some other info and generate an output file they send back. The requirement is for it to be a single EXE.

However, with all my code in one project, and no dependencies outside .NET itself, I'm getting [application].exe and [application].dll. This is not acceptable, and I cannot find an option that disables this.

Does anyone know where this is, or do I have to go back to VS 2015?

Thanks.

Upvotes: 0

Views: 700

Answers (1)

Daniel
Daniel

Reputation: 16464

This is the new normal for .NET Core / .NET 5: the .exe is a wrapper that starts the .NET run time, and all your application code is in the .dll.

You have two options:

  • You can go back to .NET Framework 4.x (no need to downgrade VS for that -- you can use VS2019 with C# 9 targeting .NET 4.x)
  • You can look into .NET 5 single-file deployment. Note that this will require the "Publish" step to generate the single file; the normal result of the "Build" step will still be .exe+.dll.
    • You can use a "Framework-dependent" publish to avoid including the .NET runtime with your application (this avoids the separate native runtime dlls)
    • Or you could use /p:IncludeNativeLibrariesInSingleFile=true /p:IncludeNativeLibrariesForSelfExtract=true to force the native runtime dlls to be included in the .exe file.

Upvotes: 1

Related Questions