0

I'm trying to optimise the size of my application package. Targeting .NET5.0

When I run the following commands:

dotnet new console -o MyConsole
cd MyConsole
dotnet publish -r win-x64 -c release --self-contained

I get a distributable version of my blank console application.

If I navigate to the MyConsole/bin/release/net5.0/win-x64/ folder I see lots of DLLs generated. Those that are not even used by the blank console application.

Are all the DLLs necessary for distribution of my application?

Is there an easy way for me to remove the DLLs that I don't need?

I could remove the DLLs one by one from MyConsole.deps.json until the executable no longer works but this doesn't seem right.

The MSFT docs mention a larger deployment but is it possible to optimise it? Similar SO

Serge P
  • 1,591
  • 8
  • 22
  • 42

1 Answers1

0

EDIT: try using

dotnet publish -r win-x64 -c Release /p:PublishSingleFile=true

source: https://dotnetcoretutorials.com/2019/06/20/publishing-a-single-exe-file-in-net-core-3-0/

What you referenced was a .NET core web app which is very different. Where as what you have is a .NET console app, however, once you build your application, depending on what you are building, you may only need the .exe file from your /bin/release folder anyways.

Brnsn
  • 33
  • 6