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

Exclude assemblies from NativeAOT app bundles #18532

Merged
merged 1 commit into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions dotnet/targets/Xamarin.Shared.Sdk.targets
Original file line number Diff line number Diff line change
Expand Up @@ -1321,6 +1321,17 @@
</ItemGroup>
</Target>

<Target Name="_ExcludeUnusedFilesFromTheBundle"
Condition="'$(_UseNativeAot)' == 'true'"
AfterTargets="_LinkNativeExecutable"
BeforeTargets="CopyFilesToPublishDirectory">
<ItemGroup>
<!-- We don't ship assemblies with NativeAOT -->
<!-- Exclude assemblies explicitly until https://github.com/dotnet/runtime/issues/87187 is not resolved -->
<ResolvedFileToPublish Remove="@(ResolvedFileToPublish)" Condition="'%(ResolvedFileToPublish.Extension)' == '.dll'" />
</ItemGroup>
</Target>

<PropertyGroup>
<_GenerateBindingsDependsOn>
_ComputeBindingVariables;
Expand Down
2 changes: 2 additions & 0 deletions runtime/coreclr-bridge.m
Original file line number Diff line number Diff line change
Expand Up @@ -558,9 +558,11 @@
void
xamarin_bridge_register_product_assembly (GCHandle* exception_gchandle)
{
#if !defined (NATIVEAOT)
MonoAssembly *assembly;
assembly = xamarin_open_and_register (PRODUCT_DUAL_ASSEMBLY, exception_gchandle);
xamarin_mono_object_release (&assembly);
#endif // !defined (NATIVEAOT)
}

MonoMethod *
Expand Down
7 changes: 5 additions & 2 deletions runtime/monotouch-main.m
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ - (void) memoryWarning: (NSNotification *) sender
if (xamarin_register_assemblies != NULL)
xamarin_register_assemblies ();

#if !defined (NATIVEAOT)
if (xamarin_executable_name) {
assembly = xamarin_open_and_register (xamarin_executable_name, &exception_gchandle);
xamarin_process_fatal_exception_gchandle (exception_gchandle, "An exception occurred while opening the main executable");
Expand All @@ -454,14 +455,16 @@ - (void) memoryWarning: (NSNotification *) sender
xamarin_process_fatal_exception_gchandle (exception_gchandle, "An exception occurred while opening an assembly");
}

#if SUPPORTS_DYNAMIC_REGISTRATION
if (xamarin_supports_dynamic_registration) {
MonoReflectionAssembly *rassembly = mono_assembly_get_object (mono_domain_get (), assembly);
xamarin_register_entry_assembly (rassembly, &exception_gchandle);
xamarin_mono_object_release (&rassembly);
xamarin_process_fatal_exception_gchandle (exception_gchandle, "An exception occurred while opening the entry assembly");
}
#endif // SUPPORTS_DYNAMIC_REGISTRATION
#else
assembly = NULL;
(void)exception_gchandle;
#endif // !defined (NATIVEAOT)

DEBUG_LAUNCH_TIME_PRINT ("\tAssembly register time");

Expand Down