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

Don't set UseApphost or SelfContained to true for PublishAot #33229

Closed
wants to merge 2 commits into from

Conversation

MichalStrehovsky
Copy link
Member

Fixes dotnet/runtime#79575.

UseAppHost doesn't make any sense for PublishAot, and neither do the behaviors around SelfContained - if SelfContained is true, the bin directory gets populated with a ton of garbage files we don't need during publish, and the publish process starts to have opinions about whether UseAppHost=true should be specified.

Cc @dotnet/ilc-contrib @ViktorHofer

Fixes dotnet/runtime#79575.

AppHost doesn't make any sense for PublishAot, and neither do the behaviors around SelfContained - if SelfContained is true, the bin directory gets populated with a ton of files we don't need during publish.
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-External untriaged Request triage from a team member labels Jun 14, 2023
@@ -173,6 +172,7 @@ Copyright (c) .NET Foundation. All rights reserved.
$([MSBuild]::VersionLessThan($(_TargetFrameworkVersionWithoutV), '8.0'))">true</SelfContained>

<SelfContained Condition="'$(SelfContained)' == ''">false</SelfContained>
<SelfContained Condition="'$(PublishAot)' == 'true' and '$(_IsPublishing)' == 'true'">false</SelfContained>
Copy link
Member

Choose a reason for hiding this comment

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

Technically we should set PublishSelfContained=true as the app will be self-contained and some things might change behavior based on that. But that setting is also broken :-(
I just wonder if setting it to false will break something somewhere because it will now think we're publishing an FDD app.

Copy link
Member Author

Choose a reason for hiding this comment

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

The problem is that we're not doing either - I couldn't find a single behavior of SelfContained=true in the SDK that looks desirable for PublishAot. I don't think FDD behaviors are desirable either but I don't see any of them getting in the way the way SelfContained is so FDD just looks like a path of least resistance. The nice side effect of setting SelfContained to false is that publish is becoming faster because we no longer copy 100 files to the bin directory that Defender needs to scan.

@ivanpovazan
Copy link
Member

@rolfbjarne @steveisok @kotlarmilos just a heads-up

@ViktorHofer ViktorHofer requested a review from jkotas June 14, 2023 10:35
@ViktorHofer
Copy link
Member

ViktorHofer commented Jun 14, 2023

Just making sure that you saw @jkotas comment in the tracking issue: dotnet/runtime#79575 (comment)

We do want to keep using app host for dotnet run or F5 in Visual Studio. I do not think we want to change the global default to false when PublishAot is set.

I guess with your change the dotnet run and F5 scenario isn't impacted as they don't use the publishing output?

@MichalStrehovsky
Copy link
Member Author

Just making sure that you saw @jkotas comment in the tracking issue: dotnet/runtime#79575 (comment)

We do want to keep using app host for dotnet run or F5 in Visual Studio. I do not think we want to change the global default to false when PublishAot is set.

That's what _IsPublishing is supposed to guard against.

@steveisok
Copy link
Member

I understand the reason for the change, but nativeaot is self contained. Are we doing something out of order in the build?

@agocke
Copy link
Member

agocke commented Jun 29, 2023

@MichalStrehovsky
Copy link
Member Author

I understand the reason for the change, but nativeaot is self contained. Are we doing something out of order in the build?

The problem is what SelfContained does in the Sdk - and we don't want pretty much any of those behaviors.

I still want to explore an alternative approach (allow SelfContained=true and just suppress the useless behaviors. If so just passing --self-contained to publish with aot doesn't error out. I just didn't have time to come back to this yet.

@nagilson
Copy link
Member

_IsPublishing will never activate in VS and only when doing dotnet publish in the SDK, is this the behavior you had expected?

cc @richlander for heads up of this PR to revert SelfContained implication for PublishAot

@nagilson nagilson removed the untriaged Request triage from a team member label Jul 26, 2023
@MichalStrehovsky
Copy link
Member Author

The problem this is trying to fix is that if someone takes a project and just wants to publish it as native aot, we'll end up downloading apphost and downloading the entire runtime pack, copy all of that into bin (as part of Build) and then do the actual native aot publish that doesn't need any of this because we don't publish the result of Build. So we just copy around a 100 MB of garbage.

It is wasteful but it wouldn't be the first wasteful thing the SDK is doing. Which is also why I didn't get back to this yet because maybe it doesn't move the needle enough.

I am ambivalent to fixing this. The current behavior makes publish slower and less efficient, but a lot of things in the SDK are already slow and inefficient. I'm honestly leaning towards just closing this and won't fixing the issue, especially given #33229 (comment) it's not possible for this optimization to kick in within VS.

@richlander
Copy link
Member

richlander commented Jul 27, 2023

Seems like a good direction to me.

AppHost and SelfContained are CoreCLR concepts.

There is an element of similarity with this issue: #34198

@akoeplinger
Copy link
Member

I think we're currently relying on the SelfContained publish behavior regarding runtime packs in the NativeAOT iOS scenario. I do agree that a lot of this is wasteful but I'd be more comfortable if we look into this for .NET 9.

@richlander
Copy link
Member

The SDK has a different bar. A middle ground is to defer it to 8.0.200.

@akoeplinger
Copy link
Member

I'm pretty sure it'd need corresponding workload changes in dotnet/runtime though.

@richlander
Copy link
Member

Got it. Then, waiting for next release is likely the best choice.

@nagilson nagilson added breaking-change Using this label will notify dotnet/compat and trigger a request to file a compat bug needs-breaking-change-doc-created labels Aug 1, 2023
@ghost
Copy link

ghost commented Aug 1, 2023

Added needs-breaking-change-doc-created label because this PR has the breaking-change label.

When you commit this breaking change:

  1. Create and link to this PR and the issue a matching issue in the dotnet/docs repo using the breaking change documentation template, then remove this needs-breaking-change-doc-created label.
  2. Ask a committer to mail the .NET Breaking Change Notification DL.

Tagging @dotnet/compat for awareness of the breaking change.

@MichalStrehovsky
Copy link
Member Author

I now learned some new things while investigating dotnet/runtime#95496 and I no longer want to pursue this.

@MichalStrehovsky MichalStrehovsky deleted the MichalStrehovsky-patch-1 branch December 1, 2023 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-External breaking-change Using this label will notify dotnet/compat and trigger a request to file a compat bug needs-breaking-change-doc-created
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Publishing as NativeAOT should not depend on AppHost
9 participants