Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define precedence relationship with MSBuild properties and CLI args #26447

Open
richlander opened this issue Jul 6, 2022 · 4 comments
Open
Assignees
Labels
Milestone

Comments

@richlander
Copy link
Member

I was defining some intended UX at #26028 (comment). I realized that I didn't understand the precedence relationship in MSBuild and the CLI. If this is documented, it would have great to have the link. If not, we should document the behavior.

There are a few scenarios I have in mind. I'm sure that there are other ways to mix these things up. These are the ones that came to mind for me.

Overlapping properties

Flip the properties in various ways.

<SelfContained>true</SelfContained>
<PublishSelfContained>false</PublishSelfContained>

and

dotnet publish

Overlapping properties, between XML and the "MSBuild" CLI

<PublishSelfContained>false</PublishSelfContained>

and

dotnet publish -p:SelfContained=true

Overlapping properties, between XML and the CLI

<PublishSelfContained>false</PublishSelfContained>

and

dotnet publish --self-contained true
@marcpopMSFT
Copy link
Member

As far as I know, the CLI always wins. In both of the above scenarios, this is the case. I'm sure there might be cases where it doesn't work but that'd have to be related properties rather than matching properties. I don't believe PublishSelfContained has been implemented yet so I don't know how to answer your questions of competing project properties yet but for competing project properties, I don't think it's entirely predictable.

@marcpopMSFT marcpopMSFT added this to the Discussion milestone Jul 12, 2022
@marcpopMSFT marcpopMSFT removed the untriaged Request triage from a team member label Jul 12, 2022
@richlander
Copy link
Member Author

When we implement PublishSelfContained, it would be good to document the expected behavior somewhere and to ensure we either don't implement features with unpredictable behavior or document the narrow cases where they are unpredictable.

@baronfel
Copy link
Member

The most relevant documentation we have is on MSBuild Properties in the conceptual docs, specifically the section on global properties.

This is a common pit of failure for users, especially at solution-level builds. CLI-specified properties override project-local properties for the entire build, which often means that CLI properties are not the correct vehicle for any kind of logic that can vary.

@jaredpar has asked for something like --local-property in the past, which would ideally behave as a normal MSBuild Property with an initial value, but would otherwise participate in build logic and be overridable.

@jaredpar
Copy link
Member

@jaredpar has asked for something like --local-property in the past, which would ideally behave as a normal MSBuild Property with an initial value, but would otherwise participate in build logic and be overridable.

Indeed. Essentially anything that let me set the initial property of a value for a build. This would just set a default initial value but have no other effect. The resulting property could be mutated just like any other property in subsequent build steps. I find the fact that -p prorties are global and immutable is generally confusing to customers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants