PublishTrimmed should imply self-contained
See original GitHub issueDoing the following steps:
dotnet new console
dotnet publish -p:PublishTrimmed=true
Results in the following error:
C:\Users\eerhardt\.nuget\packages\microsoft.net.illink.tasks\8.0.100-1.22619.1\build\Microsoft.NET.ILLink.targets(196,5): error NETSDK1102: Optimizing assemblies for size is not supported for
the selected publish configuration. Please ensure that you are publishing a self-contained app. [C:\DotNetTest\Net8Console\Net8Console.csproj]
However, doing
dotnet publish -p:PublishAot=true
- -or-
dotnet publish -p:PublishSingleFile=true
Just works without more command line args.
We should make PublishTrimmed=true
imply SelfContained=true
, just like PublishAot=true
and PublishSingleFile=true
does. That way users don’t need to pass extra args on the command line, just to make this work.
If in the future we want to support a mode where PublishTrimmed=true
, but SelfContained=false
, those customers can explicitly --self-contained false
. This is consistent with the current PublishSingleFile=true
behavior. By default it is self-contained. And you can opt into Framework Dependent Deployment with dotnet publish -p:PublishSingleFile=true --self-contained false
.
Issue Analytics
- State:
- Created 8 months ago
- Reactions:2
- Comments:93 (92 by maintainers)
Top Results From Across the Web
Trim self-contained applications - .NET
Learn how to trim self-contained apps to reduce their size. ... <PublishTrimmed> should be set in the project file so that trim-incompatible ...
Read more >Should I use self-contained or framework-dependent ...
In this post I compare the impact of the framework-dependent vs self-contained mode on Docker image size, taking layer caching into account.
Read more >.net - How to publish a self-contained C# executable that ...
The easiest way I've found to do this is to make a separate self-contained build of B and then simply copy over the...
Read more >Publishing a self-contained single-file .NET 5 executable
A self-contained . NET application is one that doesn't rely on there being any shared components on the target machine (such as the...
Read more >Making a tiny .NET Core 3.0 entirely self-contained single ...
Here is a .NET Core 3.0 Hello World app. 225 files, 69 megs. Now I'll open the csproj and add PublishTrimmed = true....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve read all the reasoning here, and while I don’t fault the logic, I find the fact that
PublishAot
will now simply error withoutPublishSelfContained
also being specified a strange UX for us to default to, especially when we seem to believe it’s extremely unlikely we’d ever support AOT with FDD apps.These properties enable analyzers that warn about the form factor incompatibilities in the inner dev loop.
Setting these properties via command line is not a pit of success.