Skip to content

Conversation

@grendello
Copy link
Contributor

Fixes: #5838
Context: e0da1f1

Partially reverts 522d7fb which
reverted d13d0f9

The $(AndroidEnablePreloadAssemblies) property controls
whether or not all .dll files contained within a .apk are
loaded during process startup. Not doing so reduces process
startup times, which is desirable, but this also caused certain
Xamarin.Forms apps to fail to run as they previously had, as
not loading all assemblies during startup broke their
Dependency Injection infrastructure.

For .NET 6, we feel we have some "wiggle-room" to change default
semantics, so for .NET 6 projects set the default value of
$(AndroidEnablePreloadAssemblies) to False, so that assemblies are
not pre-loaded during process startup.

$(AndroidEnablePreloadAssemblies) can be set to True within the
app's .csproj file to return to "legacy" semantics. This will
cause all assemblies to be loaded during startup, with a
commensurate increase in app startup overheads.

…#5790)

Fixes: dotnet#5838
Context: e0da1f1

Partially reverts 522d7fb which
reverted d13d0f9

The [`$(AndroidEnablePreloadAssemblies)`][0] property controls
whether or not *all* `.dll` files contained within a `.apk` are
loaded during process startup.  *Not* doing so reduces process
startup times, which is desirable, but this also caused certain
Xamarin.Forms apps to fail to run as they previously had, as
not loading all assemblies during startup broke their
Dependency Injection infrastructure.

For .NET 6, we feel we have *some* "wiggle-room" to change default
semantics, so for .NET 6 projects set the default value of
`$(AndroidEnablePreloadAssemblies)` to False, so that assemblies are
*not* pre-loaded during process startup.

`$(AndroidEnablePreloadAssemblies)` can be set to True within the
app's `.csproj` file to return to "legacy" semantics.  This will
cause all assemblies to be loaded during startup, with a
commensurate increase in app startup overheads.

[0]: https://docs.microsoft.com/en-us/xamarin/android/deploy-test/building-apps/build-properties#androidenablepreloadassemblies
Copy link
Member

@jonathanpeppers jonathanpeppers left a comment

Choose a reason for hiding this comment

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

It looks like the lint-related tests are failing on main, so we can ignore those.

This one looks good, since this test passes now:

image

@jonpryor jonpryor merged commit 4ed6a22 into dotnet:main May 7, 2021
@grendello grendello deleted the disable-assembly-preload-by-default branch May 7, 2021 20:44
@github-actions github-actions bot locked and limited conversation to collaborators Jan 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.NET 6: $(AndroidEnablePreloadAssemblies)=False by default

4 participants