Create a Trimmed Self-Contained Single Executable in .NET Core

Costas

Administrator
Staff member
JavaScript:
//output folder = 68mb
dotnet publish -r win-x64 -c Release --self-contained
The above command builds the app in release mode and publishes the self-contained app. This will create a folder with the application .exe and other dependencies.


Introduces a flag called PublishSingleFile which produces a single .exe file
JavaScript:
//output folder = 68mb
dotnet publish -r win-x64 -c Release /p:PublishSingleFile=true

A new flag called PublishTrimmed which doesn’t include DLL’s that aren’t used to reduced the size. You need to use both the flags together to create a Trimmed Self-Contained Single Executable in .NET Core 3.0.
JavaScript:
//output folder = 29mb
dotnet publish -r win-x64 -c Release /p:PublishSingleFile=true /p:PublishTrimmed=true

src - https://www.talkingdotnet.com/create-trimmed-self-contained-executable-in-net-core-3-0/
 
Top