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

Allow Opt-In to change the default to Release for Pack/Pub #25991

Merged
merged 23 commits into from
Jun 25, 2022

Conversation

nagilson
Copy link
Member

@nagilson nagilson commented Jun 13, 2022

Fix for #23551 (comment). Drafting until unit tests are added to assure this works. Fixes the issue, but unlike the fix in this PR #25926 it adds a property through MSBuild.

A concern:

  • Do we want a separate property to provide more granular control over Release for pack and publish? I used one for now, I think that use case is quite rare. (YES)

@nagilson nagilson self-assigned this Jun 13, 2022
@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label.

@nagilson nagilson marked this pull request as ready for review June 17, 2022 19:24
@nagilson nagilson requested review from AntonLapounov, a team and vijayrkn as code owners June 17, 2022 19:24
@nagilson nagilson requested a review from baronfel June 17, 2022 19:25
@nagilson
Copy link
Member Author

nagilson commented Jun 17, 2022

These unrelated tests, and some centered around it, fail here, but they are also failing on main. Should probably make an issue for that? Discussed that it's OK to review this nonetheless.

NativeAotStaticLib_only_runs_when_switch_is_enabled
It_publishes_the_project_with_a_refs_folder_and_correct_deps_file
ItReturnsACommandSpecWhenToolIsInAProjectRef
ItRestoresWithTheSpecifiedVerbosity

@nagilson nagilson requested a review from joeloff June 17, 2022 19:28
@nagilson
Copy link
Member Author

@joeloff If there is a concern with this breaking VS Publish, please reach out to me to discuss.

@joeloff
Copy link
Member

joeloff commented Jun 17, 2022

@joeloff If there is a concern with this breaking VS Publish, please reach out to me to discuss.

I'll let @vijayrkn weigh in on this, but I think VS should be fine. In VS, the publishing wizard usually lets you choose the configurations and I believe it is also stored in the profile. The wizards usually trigger a solution build programmatically and should be passing a value for the Configuration property.

@nagilson
Copy link
Member Author

nagilson commented Jun 22, 2022

Ok, the feature is opt-in now instead of by default. If the build succeeds and no more tests need to be fixed, would appreciate a final review before merging. Shall I also raise a PR reflecting this change here: docs/msbuild-props.md at main · dotnet/docs (github.com) ?

@richlander
Copy link
Member

LGTM ... Yes, a PR on docs would be great.

Thanks!

@@ -15,12 +15,14 @@ Copyright (c) .NET Foundation. All rights reserved.
<!-- This property disables the conflict resolution logic from the Microsoft.Packaging.Tools package, which is superceded by the logic here in the SDK -->
<DisableHandlePackageFileConflicts>true</DisableHandlePackageFileConflicts>
</PropertyGroup>

Copy link
Member

Choose a reason for hiding this comment

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

nit: can you remove the extra space?

Copy link
Member Author

@nagilson nagilson Jun 23, 2022

Choose a reason for hiding this comment

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

Yes, thanks for the call here on these artifacts.

I installed this extension now https://marketplace.visualstudio.com/items?itemName=mynkow.FormatdocumentonSave&ssr=false#overview so these artifacts of removed changes shouldn't reoccur. Sadly there were some problems elsewhere in the file that also got changed. Not sure if that's going to be annoying in the future if my auto-formatter is fixing the format of code that's in the same file but not relevant to my changes? (IMO it's better to fix the formatting everywhere if the file is being touched anyways, but will make the PRs uglier)

Copy link
Member

@baronfel baronfel left a comment

Choose a reason for hiding this comment

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

There are a few files where the only changes are whitespace, like the Publish.targets and WebSdk Publish props. Can you revert those whitespace-only changes to minimize diffs/reduce visual clutter?

Copy link
Member

@dsplaisted dsplaisted left a comment

Choose a reason for hiding this comment

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

I haven't been involved in the recent conversations around this, but I don't get what's going on here. With this PR, it looks like if you set PackRelease or PublishRelease to true, then all builds (whether doing a pack, publish, or a normal build) will be set to release by default.

Is this the intention? I would expect that if you set PublishRelease to true, that would change the default configuration for publish, but non-publish builds would still use Debug.

Code cleanup

Fix whitespace issues

Fix whitespace again

[SQUASHED] Code Cleanup Changes
@nagilson
Copy link
Member Author

nagilson commented Jun 23, 2022

@dsplaisted

Is this the intention? I would expect that if you set PublishRelease to true, that would change the default configuration for publish, but non-publish builds would still use Debug.

Yikes, with these new changes that is a problem and I should've considered the implications more. Thank you, will work on that! But I don't think we can tell which command is going to be done early enough for this change to be made here. (Maybe in the MsBuild Invocation target?) But then there are concerns of setting the Configuration later down in the chain. Will talk to @joeloff about this.

Resolved

@nagilson nagilson changed the title Update the default to Release for Pack/Pub in command building Allow Opt-In to change the default to Release for Pack/Pub Jun 23, 2022
@richlander
Copy link
Member

I would expect that if you set PublishRelease to true, that would change the default configuration for publish, but non-publish builds would still use Debug.

@dsplaisted -- That is indeed the intention.

@nagilson nagilson requested a review from dsplaisted June 23, 2022 19:48
@dsplaisted
Copy link
Member

@richlander Note that as it currently stands, PublishRelease will affect dotnet publish, but not something like dotnet build /t:Publish. That's the best we think we can do, because if you're just calling msbuild targets we don't know during evaluation which ones are going to be called.

Same thing goes for PackRelease and dotnet pack.

@nagilson
Copy link
Member Author

Note that as it currently stands, PublishRelease will affect dotnet publish, but not something like dotnet build /t:Publish. That's the best we think we can do, because if you're just calling msbuild targets we don't know during evaluation which ones are going to be called.

Yep, called that out here: #23551 (comment)

nagilson added a commit to dotnet/docs that referenced this pull request Jun 24, 2022
* The pack property was included here because it is specific to the SDK and not part of MSBuild. 
Reflects the changes we're adding here dotnet/sdk#25991
@nagilson nagilson enabled auto-merge June 24, 2022 18:47
@EskeRahn
Copy link

EskeRahn commented Aug 8, 2022

@richlander Note that as it currently stands, PublishRelease will affect dotnet publish, but not something like dotnet build /t:Publish. That's the best we think we can do, because if you're just calling msbuild targets we don't know during evaluation which ones are going to be called.

Same thing goes for PackRelease and dotnet pack.

Any way to set this would certainly be an improvement, but will it not be a cause of confusion having them acting differently?
But why not extend the idea and add a new option: dotnet build /t:PublishRelease and perhaps even dotnet publishrelease?

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

Successfully merging this pull request may close these issues.

6 participants