dotnet / dotnet/sdk

'Unlink' the implementation of `--self-contained` from the MSBuild project property `SelfContained`

Open
#53,970 2 comments 0 reactions 1 assignee Claimed by @baronfel View on GitHub
Area-NetSDK cli-ux untriaged
Dominant language
C#
Stars
3.2k
Forks
1.3k
PR merge metrics
PR metrics pending

Description

### Is your feature request related to a problem? Please describe.

`--self-contained` currently directly sets the value of the `SelfContained` MSBuild property, which can lead to nonsensical combinations of behavior.

For example, a `PublishAOT=true` application will _always_ be self-contained, and so `--self-contained false` should either error with a clear error, or mean nothing at all.

### Describe the solution you'd like

To do this, we need to separate the implementation detail of the `--self-contained` flag today - instead of directly setting `SelfContained`, which would be forcibly set due to MSBuild's global-property-from-command-line semantics, we should set a different, private property that we use to compute the final `SelfContained` property value. This would allow the SDK targets to deliver a targeted error experience _or_ silently address the problem by ignoring the `false` for cases like PublishAOT where the behavior is implicitly required.

This has become more of a problem since https://github.com/dotnet/sdk/pull/52333 fixed the behavior of `--self-contained` to always parse the boolean value the user provided - see https://github.com/dotnet/runtime/issues/127049 for an example of how users experience this.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.