question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:open
  • Created 5 months ago
  • Reactions:3
  • Comments:13 (13 by maintainers)

github_iconTop GitHub Comments

3reactions
ericstjcommented, May 11, 2023

Isn’t the whole point of PublishSelfContained to be different from SelfContained? 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 on SelfContained.

1reaction
agockecommented, May 17, 2023

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found