Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
456 views
in Technique[技术] by (71.8m points)

visual studio - Why do .NET 5 projects create two identically named DLLs, one in the main binaries folder and one in a refs subfolder, in addition to the EXE?

If I build a .NET 5 project that produces an executable, I get the following files:

  • bin/Debug/net5.0-windows/MyProject.exe
  • bin/Debug/net5.0-windows/MyProject.dll
  • bin/Debug/net5.0-windows/ref/MyProject.dll

Why are all these three files created? Older versions of .NET just generated an EXE. Why do we need two identically named DLLs in different folders to go along with the EXE?

question from:https://stackoverflow.com/questions/65947102/why-do-net-5-projects-create-two-identically-named-dlls-one-in-the-main-binari

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

MyProject.exe:
Platform-specific executable generated for convenience so you don't need to write dotnet MyProject.dll to start application.
According to documentation .NET SDK 2.1 was not producing it.

MyProject.dll:
Main application dll - cross-platform dll with entry point.
You have the option to put it inside platform-specific .exe by using Single file deployment and executable https://docs.microsoft.com/en-us/dotnet/core/deploying/single-file

ref/MyProject.dll:
Dll for some runtime compilation by other tools. Described in @Andrew's answer. Generation can be disabled by the compiler option.

Summary
With cross-platform .NET Core you can distribute your application in many different ways but the price comes with new levels of indirections and new compiler options.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...