PublishSelfContained should not do a self-contained build
See original GitHub issue<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PublishSelfContained>true</PublishSelfContained>
</PropertyGroup>
</Project>
Run dotnet publish
.
The output in ./bin/Release/net8.0/linux-x64/publish
is self-contained, as expected. What’s unexpected is that the build output in /bin/Release/net8.0/linux-x64
is also self-contained. This is true even if I add <SelfContained>false</SelfContained>
.
Issue Analytics
- State:
- Created 5 months ago
- Reactions:3
- Comments:13 (13 by maintainers)
Top Results From Across the Web
NET application publishing overview
When publishing your app and creating an executable, you can publish the app as self-contained or framework-dependent. Publishing an app as ...
Read more >error NETSDK1031: It is not supported to build or publish a ...
I am running following command to publish .NET CORE 5.0 web api project using command line on windows 10 box. c:\test\Service>dotnet publish -c ......
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 >Self-contained publish/build error · Issue #21677 · dotnet/sdk
When I try to do a self-contained build and publish of an app I wish to publish to App Service prior to RC2...
Read more >Self-Contained Applications: Great Tool in .NET 8
NET applications: the self-contained application's output publishing folder has all the components it needs, even .NET!
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
Isn’t the whole point of
PublishSelfContained
to be different fromSelfContained
? The way I imagine this working is that build is not self-contained. Then during publish the app would get a new runtimeconfig, a copy of the runtime pack, specialization of runtimeTargets for the specific runtime - as well as anything else during build that depends onSelfContained
.I should mention, this would be solved completely by my proposal to make SelfContained only occur during Publish.
If we decide to go that route (and take the breaking change), we would change the behavior of PublishSelfContained as well (arguably we could delete PublishSelfContained entirely, as it is the same thing).
As it is, it feels like the PublishSelfContained design is broken. It doesn’t achieve what we wanted it to achieve (only create a self-contained layout during Publish) and now fixing it would be another breaking change.
The original proposal of obsoleting build-self-contained is looking even more attractive to me now.