Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET Core publish produces lots of DLLs in the published folder, why?

I created a simple Web API project in Visual Studio 2015 using the .NET Core Framework. When I publish this project using the default settings, it creates the following:

enter image description here

In total there are 155 DLLs, 77 in the PublishOutput root and 78 in the refs folder.

  • Why put all the DLLs in the publish folder? Couldn't it just reference the DLLs where they were installed from a single shared location ?
like image 804
Exocomp Avatar asked Dec 15 '16 17:12

Exocomp


People also ask

What does .NET core publish do?

dotnet publish compiles the application, reads through its dependencies specified in the project file, and publishes the resulting set of files to a directory. The output includes the following assets: Intermediate Language (IL) code in an assembly with a dll extension. A .

What is the use of publish in Visual Studio?

Visual Studio can help you manage dependencies to Azure services. When you use the Publish tool to deploy your application to Azure, you get the opportunity to configure dependencies to Azure services.

What is DLL refresh file in asp net?

These files give the path to the DLL in question to tell Visual Studio where to find it (you can check this if you open them in a text editor). They will be created each time you add a new reference to the project.

What is the difference between dotnet build and dotnet publish?

Build compiles the source code into a (hopefully) runnable application. Publish takes the results of the build, along with any needed third-party libraries and puts it somewhere for other people to run it.


2 Answers

Dotnet core tend to be very minimal as opposed to the previous versions of .net framework.

In dotnet core, the main purpose was making the core framework as small as possible and if you need more stuff, bring it in through NuGet packages.

So, many dependencies that used to be available in the framework are now moved to the NuGet packages and as you know there is a chain of dependencies in NuGet packages, so we will end up with so many libraries in our publish output, which is fine.

Another point being, most of the time, we're using project templates with too many dependencies that might not be needed whatsoever. So we can either start with a very minimal template and add needed stuff in it, or remove useless stuff from a more chuncky template.

like image 141
akardon Avatar answered Sep 25 '22 19:09

akardon


I had a similar issue. When my local computer was upgraded from Net Core 2.0 to 2.1, my Core We Application which references a NetStandard application started publishing all DLL's in all referenced projects. I migrated my Core 2.0 application to 2.1 to match the highest version of SDK installed on my local and I could see my issue is now resolved. Publishing from the migrated(upgraded) application produced only the required DLL's. Hope this helps.

like image 44
TheCopyPaster Avatar answered Sep 26 '22 19:09

TheCopyPaster