-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Conversation
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.
@@ -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> |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
@rolfbjarne @steveisok @kotlarmilos just a heads-up |
Just making sure that you saw @jkotas comment in the tracking issue: dotnet/runtime#79575 (comment)
I guess with your change the |
That's what |
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 |
_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 |
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. |
Seems like a good direction to me. AppHost and SelfContained are CoreCLR concepts. There is an element of similarity with this issue: #34198 |
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. |
The SDK has a different bar. A middle ground is to defer it to 8.0.200. |
I'm pretty sure it'd need corresponding workload changes in dotnet/runtime though. |
Got it. Then, waiting for next release is likely the best choice. |
Added When you commit this breaking change:
Tagging @dotnet/compat for awareness of the breaking change. |
I now learned some new things while investigating dotnet/runtime#95496 and I no longer want to pursue this. |
Fixes dotnet/runtime#79575.
UseAppHost
doesn't make any sense forPublishAot
, and neither do the behaviors aroundSelfContained
- ifSelfContained
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