Skip to content

Conversation

sbomer
Copy link
Member

@sbomer sbomer commented Jan 21, 2025

For the following project (note it sets PublishSelfContained):

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net10.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
    <PublishSelfContained>true</PublishSelfContained>
  </PropertyGroup>

</Project>

This command doesn't produce a self-contained publish output:

> dotnet build /t:Publish
Restore complete (0.4s)
You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy
  selfc succeeded (0.3s) → bin/Debug/net10.0/publish/

Build succeeded in 1.1s
> ls bin/Debug/net10.0/
publish  selfc  selfc.deps.json  selfc.dll  selfc.pdb  selfc.runtimeconfig.json
> ls bin/Debug/net10.0/publish/
selfc  selfc.deps.json  selfc.dll  selfc.pdb  selfc.runtimeconfig.json

This adds an error message for this unsupported scenario.

Related: #32272 (discusses the PublishSelfContained behavior with /t:Publish)
Related: dotnet/runtime#95496
Related: #46070

@sbomer sbomer requested review from a team and AntonLapounov as code owners January 21, 2025 19:10
@ghost ghost added Area-Infrastructure untriaged Request triage from a team member labels Jan 21, 2025
@github-actions
Copy link
Contributor

Due to lack of recent activity, this PR has been labeled as 'Stale'. It will be closed if no further activity occurs within 7 more days. Any new comment will remove the label.

@github-actions github-actions bot added the stale label Sep 22, 2025
Copy link
Member

@nagilson nagilson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would we want this as a warning instead of an error? This will definitely cause some breaking changes but I understand the idea. We may also want to consider this for PublishRuntimeIdentifier. Its likely too late to do this for 10 but we could do this for 11.

I think we would also want sign off from @baronfel or another PM if we wanted to do this from a product perspective. I think it's a good idea.

@baronfel
Copy link
Member

Thanks for the call-out @nagilson - definitely think there's value here, definitely agree that it's too late for 10 (our fault due to delays/time), definitely agree that it needs to be a warning, not an error, for at least a release. The error itself seems fine, it would be great if we had a help doc we could point to. I'm not sure if one exists that calls out the gaps with using /t:Publish directly.

@github-actions github-actions bot removed the stale label Sep 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-Infrastructure untriaged Request triage from a team member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants