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

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

1
2
3
4
5
6
7
8
//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
```js
//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.

1
2
//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/

origin - https://www.pipiscrew.com/?p=18629 create-a-trimmed-self-contained-single-executable-in-net-core

This post is licensed under CC BY 4.0 by the author.
Contents

Trending Tags