@@ -22,6 +22,19 @@ public class ProcessNativeLibraries : AndroidTask
22
22
"libxamarin-debug-app-helper" ,
23
23
} ;
24
24
25
+ // Please keep the list sorted. Any new runtime libraries that are added upstream need to be mentioned here.
26
+ static readonly HashSet < string > KnownRuntimeNativeLibraries = new ( StringComparer . OrdinalIgnoreCase ) {
27
+ "libSystem.Globalization.Native.so" ,
28
+ "libSystem.IO.Compression.Native.so" ,
29
+ "libSystem.Native.so" ,
30
+ "libSystem.Security.Cryptography.Native.Android.so" ,
31
+ "libmono-component-debugger.so" ,
32
+ "libmono-component-diagnostics_tracing.so" ,
33
+ "libmono-component-hot_reload.so" ,
34
+ "libmono-component-marshal-ilgen.so" ,
35
+ "libmonosgen-2.0.so" ,
36
+ } ;
37
+
25
38
/// <summary>
26
39
/// Assumed to be .so files only
27
40
/// </summary>
@@ -93,12 +106,27 @@ public override bool RunTask ()
93
106
continue ;
94
107
}
95
108
96
- output . Add ( library ) ;
109
+ if ( ! IgnoreLibraryWhenLinkingRuntime ( library ) ) {
110
+ output . Add ( library ) ;
111
+ }
97
112
}
98
113
99
114
OutputLibraries = output . ToArray ( ) ;
100
115
101
116
return ! Log . HasLoggedErrors ;
102
117
}
118
+
119
+ bool IgnoreLibraryWhenLinkingRuntime ( ITaskItem libItem )
120
+ {
121
+ // We ignore all the shared libraries coming from the runtime packages, as they are all linked into our runtime and
122
+ // need not be packaged.
123
+ string packageId = libItem . GetMetadata ( "NuGetPackageId" ) ;
124
+ if ( packageId . StartsWith ( "Microsoft.NETCore.App.Runtime.Mono.android-" , StringComparison . OrdinalIgnoreCase ) ) {
125
+ return true ;
126
+ }
127
+
128
+ // Should `NuGetPackageId` be empty, we check the libs by name, as the last resort.
129
+ return KnownRuntimeNativeLibraries . Contains ( Path . GetFileName ( libItem . ItemSpec ) ) ;
130
+ }
103
131
}
104
132
}
0 commit comments