2

I'm just trying build an example dotnet-core 2.0 console app which should be published as an execute file. This requires me to add an RuntimeIdentifier in the csproj file. After publishing my sample application for win-x64, I get a output directory which contains around 200 dlls and my executable. I have the feeling that's too much - only to print a simple Hello World to the console.

Is there a way to reduce the number of dlls? In this old (and now surely outdated document) named reducing package dependencies a manual approach is proposed for libraries.

Is there a way to reduce the dependencies in dotnet-core 2.0? Or isn't this an issue after all and I shouldn't care?

Just for completeness, here is my example project definition:

<Project Sdk="Microsoft.NET.Sdk">
     <PropertyGroup>
       <OutputType>Exe</OutputType>
       <TargetFramework>netcoreapp2.0</TargetFramework>
       <RuntimeIdentifiers>Portable;win-x64</RuntimeIdentifiers>   
     </PropertyGroup>
</Project>
ventiseis
  • 3,029
  • 11
  • 32
  • 49

1 Answers1

2

All the dependencies are useful in a certain way (some classes of each are used to make your app work), so when you say "unnecessary" you are wrong.

So far, there is no better tool than the newly announced IL Linker to shrink the size of deployment,

https://github.com/dotnet/announcements/issues/30

Lex Li
  • 60,503
  • 9
  • 116
  • 147
  • Thanks for the tip with the linker. It seems to work, but there are more dlls in the output directory, which the linker doesn't even look at. I assume these are the ones required by the .net core runtime and unrelated to my app. I would prefer a portable version anyway, but this creates no executable file, the application has to be called with `dotnet`. – ventiseis Oct 04 '17 at 19:31
  • I read the corresponding issue https://github.com/dotnet/cli/issues/6237 and see that a lot more people are confused about the deployment options. – ventiseis Oct 04 '17 at 19:33
  • 3
    https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-publish?tabs=netcore2x Clearly you should use `--self-contained`. Confusion is not surprising, but should be less and less, as the documentation is being updated quite frequently to roll new things out. – Lex Li Oct 04 '17 at 19:35