-
Notifications
You must be signed in to change notification settings - Fork 569
Expand file tree
/
Copy pathMicrosoft.Android.Sdk.NativeAOT.targets
More file actions
380 lines (330 loc) · 20.8 KB
/
Microsoft.Android.Sdk.NativeAOT.targets
File metadata and controls
380 lines (330 loc) · 20.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
<!--
***********************************************************************************************
Microsoft.Android.Sdk.NativeAOT.targets
This file contains the NativeAOT-specific MSBuild logic for .NET for Android.
***********************************************************************************************
-->
<Project>
<UsingTask TaskName="Xamarin.Android.Tasks.SetNdkPathForIlc" AssemblyFile="$(_XamarinAndroidBuildTasksAssembly)" />
<UsingTask TaskName="Xamarin.Android.Tasks.GenerateNativeAotLibraryLoadAssemblerSources" AssemblyFile="$(_XamarinAndroidBuildTasksAssembly)" />
<UsingTask TaskName="Xamarin.Android.Tasks.GenerateNativeAotEnvironmentAssemblerSources" AssemblyFile="$(_XamarinAndroidBuildTasksAssembly)" />
<UsingTask TaskName="Xamarin.Android.Tasks.LinkNativeAotSharedLibrary" AssemblyFile="$(_XamarinAndroidBuildTasksAssembly)" />
<!-- Default property values for NativeAOT -->
<PropertyGroup>
<_AndroidRuntimePackRuntime>NativeAOT</_AndroidRuntimePackRuntime>
<_AndroidJcwCodegenTarget Condition=" '$(_AndroidJcwCodegenTarget)' == '' ">JavaInterop1</_AndroidJcwCodegenTarget>
<_AndroidTypeMapImplementation Condition=" '$(_AndroidTypeMapImplementation)' == '' ">managed</_AndroidTypeMapImplementation>
<!-- .NET SDK gives: error NETSDK1191: A runtime identifier for the property 'PublishAot' couldn't be inferred. Specify a rid explicitly. -->
<AllowPublishAotWithoutRuntimeIdentifier Condition=" '$(AllowPublishAotWithoutRuntimeIdentifier)' == '' ">true</AllowPublishAotWithoutRuntimeIdentifier>
<!-- NativeAOT's targets currently gives an error about cross-compilation -->
<DisableUnsupportedError Condition=" $([MSBuild]::IsOSPlatform('windows')) and '$(DisableUnsupportedError)' == '' ">true</DisableUnsupportedError>
<!-- HACK: make dotnet restore include Microsoft.NETCore.App.Runtime.NativeAOT.linux-bionic-arm64 -->
<_IsPublishing Condition=" '$(_IsPublishing)' == '' ">true</_IsPublishing>
<!-- ResolvedFileToPublish is not populated until _AndroidComputeIlcCompileInputs, so
proguard generation must run after that target instead of after ILLink. -->
<_GenerateProguardAfterTargets>_AndroidComputeIlcCompileInputs</_GenerateProguardAfterTargets>
<!-- Ask ILC to produce a static library (.a) instead of a shared library (.so).
This gives Android full control over the native linker invocation. -->
<NativeLib>static</NativeLib>
<!-- ILC only sets this for NativeLib=Shared, but we need [UnmanagedCallersOnly] methods
exported as native symbols so JNI can find them via dlsym. -->
<IlcExportUnmanagedEntrypoints>true</IlcExportUnmanagedEntrypoints>
</PropertyGroup>
<!-- Default property values for NativeAOT Debug configuration -->
<PropertyGroup Condition="'$(DebugSymbols)' == 'true'">
<NativeDebugSymbols>true</NativeDebugSymbols>
<StripSymbols>false</StripSymbols>
<CompressSymbols>false</CompressSymbols>
</PropertyGroup>
<!-- Default feature switches -->
<ItemGroup>
<RuntimeHostConfigurationOption Include="Microsoft.Android.Runtime.RuntimeFeature.IsMonoRuntime"
Value="false"
Trim="true"
/>
<RuntimeHostConfigurationOption Include="Microsoft.Android.Runtime.RuntimeFeature.IsCoreClrRuntime"
Value="false"
Trim="true"
/>
</ItemGroup>
<!-- Make IlcCompile depend on the trimmer -->
<PropertyGroup>
<IlcCompileDependsOn>
_AndroidBeforeIlcCompile;
SetupOSSpecificProps;
PrepareForILLink;
ILLink;
ComputeIlcCompileInputs;
_AndroidComputeIlcCompileInputs;
$(IlcCompileDependsOn)
</IlcCompileDependsOn>
</PropertyGroup>
<Target Name="_AndroidBeforeIlcCompile"
DependsOnTargets="_PrepareLinking"
BeforeTargets="SetupProperties">
<!-- Example settings from: https://github.com/jonathanpeppers/Android-NativeAOT/blob/ea69d122cdc7de67aa6a5db14b7e560763c63cdd/DotNet/libdotnet.targets -->
<PropertyGroup>
<_NdkAbi Condition=" '$(RuntimeIdentifier)' == 'android-arm64' ">aarch64</_NdkAbi>
<_NdkAbi Condition=" '$(RuntimeIdentifier)' == 'android-x64' ">x86_64</_NdkAbi>
<_NDKApiLevel Condition=" '$(RuntimeIdentifier)' == 'android-arm64' ">$(AndroidNdkApiLevel_Arm64)</_NDKApiLevel>
<_NDKApiLevel Condition=" '$(RuntimeIdentifier)' == 'android-x64' ">$(AndroidNdkAPiLevel_X64)</_NDKApiLevel>
<_NdkSysrootAbi>$(_NdkAbi)-linux-android</_NdkSysrootAbi>
<_NdkPrebuiltAbi Condition=" $([MSBuild]::IsOSPlatform('windows')) ">windows-x86_64</_NdkPrebuiltAbi>
<_NdkPrebuiltAbi Condition=" $([MSBuild]::IsOSPlatform('osx')) ">darwin-x86_64</_NdkPrebuiltAbi>
<_NdkPrebuiltAbi Condition=" $([MSBuild]::IsOSPlatform('linux')) ">linux-x86_64</_NdkPrebuiltAbi>
<!-- We need to explicitly specify the extension on Windows, since some Android NDK versions
for Windows contain bash shell scripts without the extension, in addition to the
Windows-specific .cmd ones. We must use the latter since end users might not have bash
installed on Windows -->
<_NdkWrapperScriptExt Condition=" $([MSBuild]::IsOSPlatform('windows')) ">.cmd</_NdkWrapperScriptExt>
<_NdkSysrootDir>$(_AndroidNdkDirectory)toolchains/llvm/prebuilt/$(_NdkPrebuiltAbi)/sysroot/usr/lib/$(_NdkSysrootAbi)/</_NdkSysrootDir>
<_NdkBinDir>$(_AndroidNdkDirectory)toolchains/llvm/prebuilt/$(_NdkPrebuiltAbi)/bin/</_NdkBinDir>
<!--
Don't call `clang` directly, use the wrapper scripts instead since they properly pass
arguments required to link the application using the right API level libraries.
Using the script also makes it certain that we're not invoking a random `clang` in
from the system but rather the NDK one.
Also, we cannot use $(_NdkBinDir) here because, on Windows, the `Exec` task will get
confused by the forward slash in the path (even though it's a valid path separator
character on Windows) and signal the following error:
SetupOSSpecificProps:
where /Q "C:\Android\android-sdk\ndk\29.0.14206865\toolchains/llvm/prebuilt/windows-x86_64/bin/clang++"
1>EXEC : error : Invalid pattern is specified in "path:pattern".
The command "where /Q "C:\Android\android-sdk\ndk\29.0.14206865\toolchains/llvm/prebuilt/windows-x86_64/bin/clang++"" exited with code 2.
This could be fixed by making sure $(_NdkBinDir) path is fixed-up to use the canonical
form of path separation for the host OS, but it's simpler to just use the NDK-specific
compiler/linker wrapper script name.
Also, do NOT use `clang++` here because it will link the dynamic libc++ library into the
application. If, for some reason, `clang++` has to be used, `<LinkerArgs>` need to be
added to pass `-nostdlib` to it.
-->
<CppCompilerAndLinker>$(_NdkAbi)-linux-android$(_NDKApiLevel)-clang$(_NdkWrapperScriptExt)</CppCompilerAndLinker>
<CppLinker>$(_NdkAbi)-linux-android$(_NDKApiLevel)-clang$(_NdkWrapperScriptExt)</CppLinker>
<ObjCopyName>llvm-objcopy</ObjCopyName>
<!-- Use the NDK's llvm-ar instead of the host 'ar' so that ELF objects are handled
correctly when cross-compiling. -->
<CppLibCreator>llvm-ar</CppLibCreator>
<!-- We must ensure this is `false`, as it would interfere with statically linking libc++ -->
<LinkStandardCPlusPlusLibrary>false</LinkStandardCPlusPlusLibrary>
<!-- Clear LinkerFlavor: the ILC targets set it to 'lld' for android/bionic, but with NativeLib=static
the _LinkerVersion detection is skipped, causing a numeric comparison error in LinkNative.
Since we handle native linking ourselves, LinkerFlavor is not needed.
Context: https://github.com/dotnet/runtime/issues/126978 -->
<LinkerFlavor />
<!-- Example settings from: https://github.com/xamarin/xamarin-macios/blob/c43d4ea40bc777969e3b158cf46446df292d8449/dotnet/targets/Xamarin.Shared.Sdk.targets#L541-L550 -->
<RunILLink>true</RunILLink>
<!--
We want to suppress warnings from trimmer and only show warnings from ILC.
Otherwise, you would get 2x for every warning.
-->
<_OriginalSuppressTrimAnalysisWarnings>$(SuppressTrimAnalysisWarnings)</_OriginalSuppressTrimAnalysisWarnings>
<SuppressTrimAnalysisWarnings>true</SuppressTrimAnalysisWarnings>
<!-- Ensure ILLink respects the value of SuppressTrimAnalysisWarnings -->
<_ExtraTrimmerArgs>$(_ExtraTrimmerArgs) --notrimwarn</_ExtraTrimmerArgs>
</PropertyGroup>
<SetNdkPathForIlc NdkBinDirectory="$(_NdkBinDir)" />
</Target>
<Target Name="_AndroidComputeIlcCompileInputs">
<PropertyGroup>
<!-- Turn trimmer warnings back to original value -->
<SuppressTrimAnalysisWarnings>$(_OriginalSuppressTrimAnalysisWarnings)</SuppressTrimAnalysisWarnings>
</PropertyGroup>
<ItemGroup>
<!-- Android needs a proper soname property or it will refuse to load the library -->
<LinkerArg Include=""-Wl,-soname,lib$(TargetName).so"" />
<LinkerArg Include="-Wl,--error-unresolved-symbols" />
<LinkerArg Include="-Wl,--no-undefined" />
<!-- Prevent ComputeLinkedFilesToPublish from removing trimmed assemblies from
ResolvedFileToPublish. We run ILLink before ILC (to support custom trimmer
steps), so the assemblies are already trimmed and must remain in
ResolvedFileToPublish for the outer build's _ResolveAssemblies target.
Context: https://github.com/dotnet/runtime/pull/124801 -->
<_IlcManagedInputAssemblies Remove="@(_IlcManagedInputAssemblies)" />
<!-- Required for [UnmanagedCallersOnly] to work inside this assembly -->
<UnmanagedEntryPointsAssembly Include="Microsoft.Android.Runtime.NativeAOT" />
<!-- Give ILLink's output to ILC -->
<IlcCompileInput Remove="@(IlcCompileInput)" />
<IlcCompileInput Include="$(IntermediateLinkDir)$(TargetName)$(TargetExt)" />
<_AndroidILLinkAssemblies Include="@(ManagedAssemblyToLink->'$(IntermediateLinkDir)%(Filename)%(Extension)')" Condition="Exists('$(IntermediateLinkDir)%(Filename)%(Extension)')" />
<IlcReference Remove="@(IlcReference)" />
<IlcReference Include="@(PrivateSdkAssemblies)" />
<IlcReference Include="@(_AndroidILLinkAssemblies)" />
<!-- Root *everything* for ILC, as it's already trimmed -->
<TrimmerRootAssembly Include="@(_AndroidILLinkAssemblies->'%(Filename)')" Exclude="System.Private.CoreLib" TrimMode="All" />
<!-- Passes linked assemblies to outer MSBuild tasks/targets -->
<ResolvedFileToPublish Include="@(IlcCompileInput);@(_AndroidILLinkAssemblies)" RuntimeIdentifier="$(RuntimeIdentifier)" />
<!-- Satellite assemblies -->
<IlcSatelliteAssembly Include="$(_OuterIntermediateSatelliteAssembliesWithTargetPath)" />
<_NdkLibs Include="@(RuntimePackAsset->WithMetadataValue('Filename', 'libnaot-android.$(Configuration.ToLower())-static-$(Configuration.ToLower())'))" />
<!-- Include libc++ -->
<_NdkLibs Include="$(_NdkSysrootDir)libc++_static.a" />
<_NdkLibs Include="$(_NdkSysrootDir)libc++abi.a" />
<LinkerArg Include=""%(_NdkLibs.Identity)"" />
<!-- This library conflicts with static libc++ -->
<NativeLibrary Remove="$(IlcSdkPath)libstdc++compat.a" />
<LinkerArg Remove="$(IlcSdkPath)libstdc++compat.a" />
<!-- Every p/invoke using the `xa-internal-api` "library" will be called directly -->
<DirectPInvoke Include="xa-internal-api" />
</ItemGroup>
</Target>
<Target Name="_PrepareNativeAotAndroidAppInputs">
<ItemGroup>
<_PrivateBuildTargetAbi Condition=" '$(RuntimeIdentifier)' == 'android-arm64' " Include="arm64-v8a" />
<_PrivateBuildTargetAbi Condition=" '$(RuntimeIdentifier)' == 'android-x64' " Include="x86_64" />
</ItemGroup>
<PrepareAbiItems
BuildTargetAbis="@(_PrivateBuildTargetAbi)"
NativeSourcesDir="$(_NativeAssemblySourceDir)"
Debug="$(AndroidIncludeDebugSymbols)"
Mode="jni_init">
<Output TaskParameter="AssemblySources" ItemName="_PrivateJniInitFuncsAssemblySource" />
</PrepareAbiItems>
<PrepareAbiItems
BuildTargetAbis="@(_PrivateBuildTargetAbi)"
NativeSourcesDir="$(_NativeAssemblySourceDir)"
Debug="$(AndroidIncludeDebugSymbols)"
Mode="environment">
<Output TaskParameter="AssemblySources" ItemName="_PrivateEnvironmentAssemblySource" />
</PrepareAbiItems>
<ItemGroup>
<_PrivateJniInitFuncsNativeObjectFile Include="@(_PrivateJniInitFuncsAssemblySource->'$([System.IO.Path]::ChangeExtension('%(Identity)', '.o'))')">
<abi>%(_PrivateJniInitFuncsAssemblySource.abi)</abi>
</_PrivateJniInitFuncsNativeObjectFile>
<_PrivateEnvironmentNativeObjectFile Include="@(_PrivateEnvironmentAssemblySource->'$([System.IO.Path]::ChangeExtension('%(Identity)', '.o'))')">
<abi>%(_PrivateEnvironmentAssemblySource.abi)</abi>
</_PrivateEnvironmentNativeObjectFile>
<_PrivateAndroidNaotResolvedAssemblyFiles Include="@(ResolvedFileToPublish->Distinct())" Condition=" '%(ResolvedFileToPublish.Extension)' == '.dll' " />
<!-- In .NET 11+, the SDK's ILLink target populates ResolvedFileToPublish with linked assemblies
(via _LinkedResolvedFileToPublish) WITHOUT RuntimeIdentifier metadata. _AndroidComputeIlcCompileInputs
adds the same items WITH RuntimeIdentifier, but ->Distinct() keeps the first occurrence (without metadata).
Stamp RuntimeIdentifier on any items that lack it, since we're in the inner build with a single RID. -->
<_PrivateAndroidNaotResolvedAssemblyFiles
Update="@(_PrivateAndroidNaotResolvedAssemblyFiles)"
Condition=" '%(_PrivateAndroidNaotResolvedAssemblyFiles.RuntimeIdentifier)' == '' "
RuntimeIdentifier="$(RuntimeIdentifier)"
/>
</ItemGroup>
</Target>
<Target
Name="_GenerateNativeAotAndroidAppAssemblerSources"
DependsOnTargets="_GenerateEnvironmentFiles;_PrepareNativeAotAndroidAppInputs"
Inputs="@(_PrivateAndroidNaotResolvedAssemblyFiles);@(AndroidEnvironment);@(LibraryEnvironments)"
Outputs="@(_PrivateJniInitFuncsAssemblySource);@(_PrivateJniInitFuncsNativeObjectFile);@(_PrivateEnvironmentAssemblySource);@(_PrivateEnvironmentNativeObjectFile)">
<GenerateNativeAotLibraryLoadAssemblerSources
ResolvedAssemblies="@(_PrivateAndroidNaotResolvedAssemblyFiles)"
CustomJniInitFunctions="@(AndroidStaticJniInitFunction)"
OutputSources="@(_PrivateJniInitFuncsAssemblySource)" />
<GenerateNativeAotEnvironmentAssemblerSources
Environments="@(AndroidEnvironment);@(LibraryEnvironments)"
HttpClientHandlerType="$(AndroidHttpClientHandlerType)"
OutputSources="@(_PrivateEnvironmentAssemblySource)"
RID="$(RuntimeIdentifier)" />
<CompileNativeAssembly
Sources="@(_PrivateJniInitFuncsAssemblySource);@(_PrivateEnvironmentAssemblySource)"
DebugBuild="$(AndroidIncludeDebugSymbols)"
WorkingDirectory="$(_NativeAssemblySourceDir)"
AndroidBinUtilsDirectory="$(AndroidBinUtilsDirectory)" />
<ItemGroup>
<LinkerArg Include="@(_PrivateJniInitFuncsNativeObjectFile)" />
<LinkerArg Include="@(_PrivateEnvironmentNativeObjectFile)" />
</ItemGroup>
</Target>
<!-- Make sure we have a chance to generate our application-specific static library before linking
takes place. We must run after `IlcCompile`, which is a dependency of `LinkNative` -->
<Target
Name="_GenerateNativeAotAndroidAppLibrary"
AfterTargets="IlcCompile"
DependsOnTargets="_GenerateNativeAotAndroidAppAssemblerSources">
</Target>
<!--
With NativeLib=static, ILC's LinkNative target produces a .a archive via `ar`.
We need to link the ILC .o output + all NativeLibrary/system libs into a .so ourselves.
This target runs after LinkNative and uses ld.lld directly via LinkNativeAotSharedLibrary task.
-->
<Target Name="_AndroidLinkNativeAotSharedLibrary"
AfterTargets="LinkNative"
DependsOnTargets="_PrepareNativeAotAndroidAppInputs"
Inputs="$(NativeObject);@(NativeLibrary)"
Outputs="$(NativeOutputPath)$(NativeBinaryPrefix)$(TargetName).so">
<PropertyGroup>
<_AndroidNativeAotSharedLibrary>$(NativeOutputPath)$(NativeBinaryPrefix)$(TargetName).so</_AndroidNativeAotSharedLibrary>
<!-- NDK paths for CRT objects and compiler-rt -->
<_NdkApiSysrootDir>$(_NdkSysrootDir)$(_NDKApiLevel)/</_NdkApiSysrootDir>
<_NdkClangResourceDir>$(_AndroidNdkDirectory)toolchains/llvm/prebuilt/$(_NdkPrebuiltAbi)/lib/clang</_NdkClangResourceDir>
</PropertyGroup>
<ItemGroup>
<!-- CRT start file -->
<_NativeAotCrtStartFiles Include="$(_NdkApiSysrootDir)crtbegin_so.o">
<Abi>@(_PrivateBuildTargetAbi)</Abi>
</_NativeAotCrtStartFiles>
<!-- CRT end file -->
<_NativeAotCrtEndFiles Include="$(_NdkApiSysrootDir)crtend_so.o">
<Abi>@(_PrivateBuildTargetAbi)</Abi>
</_NativeAotCrtEndFiles>
<!-- Library search paths (matching what clang provides) -->
<_NativeAotLibSearchPaths Include="$(_NdkApiSysrootDir)" />
<_NativeAotLibSearchPaths Include="$(_NdkSysrootDir)" />
<!-- ILC runtime .a files are already in @(NativeLibrary) from SetupOSSpecificProps -->
<!-- Android-added libraries from _AndroidComputeIlcCompileInputs are in @(_NdkLibs) -->
<_NativeAotLinkLibraries Include="@(NativeLibrary)" />
<_NativeAotLinkLibraries Include="@(_NdkLibs)" />
<!-- Additional .o files (jni_init, environment) -->
<_NativeAotAdditionalObjects Include="@(_PrivateJniInitFuncsNativeObjectFile)" />
<_NativeAotAdditionalObjects Include="@(_PrivateEnvironmentNativeObjectFile)" />
<!-- System libraries (resolved via -L search paths) -->
<_NativeAotSystemLibraries Include="dl" />
<_NativeAotSystemLibraries Include="z" />
<_NativeAotSystemLibraries Include="log" />
<_NativeAotSystemLibraries Include="m" />
<_NativeAotSystemLibraries Include="c" />
<!-- Compiler-rt builtins and unwinder (explicit paths from NDK) -->
<_NativeAotCompilerRtLibs Include="$(_NdkClangResourceDir)/**/libclang_rt.builtins-$(_NdkAbi)-android.a" />
<_NativeAotCompilerRtLibs Include="$(_NdkClangResourceDir)/**/$(_NdkAbi)/libunwind.a" />
</ItemGroup>
<LinkNativeAotSharedLibrary
AndroidBinUtilsDirectory="$(_NdkBinDir)"
IntermediateOutputPath="$(NativeIntermediateOutputPath)"
RuntimePackLibraryDirectories="@(RuntimePackLibraryDirectories)"
NativeObject="$(NativeObject)"
OutputSharedLibrary="$(_AndroidNativeAotSharedLibrary)"
NativeLibraries="@(_NativeAotLinkLibraries)"
AdditionalObjectFiles="@(_NativeAotAdditionalObjects)"
CrtStartFiles="@(_NativeAotCrtStartFiles)"
CrtEndFiles="@(_NativeAotCrtEndFiles)"
CompilerRuntimeLibraries="@(_NativeAotCompilerRtLibs)"
SystemLibraries="@(_NativeAotSystemLibraries)"
LibrarySearchPaths="@(_NativeAotLibSearchPaths)"
ExportsFile="$(ExportsFile)"
LinkerScript="$(NativeIntermediateOutputPath)sections.ld"
LinkerScriptContent="OVERWRITE_SECTIONS { __modules : { KEEP(*(__modules)) } }"
SupportedAbis="@(_PrivateBuildTargetAbi)"
DebugBuild="$(AndroidIncludeDebugSymbols)"
/>
<ItemGroup>
<!-- Replace the .a that NativeCompile/ComputeLinkedFilesToPublish would publish with our .so -->
<ResolvedFileToPublish Remove="@(ResolvedFileToPublish)" Condition=" '%(Filename)%(Extension)' == '$(TargetName).a' " />
<ResolvedFileToPublish Include="$(_AndroidNativeAotSharedLibrary)">
<RelativePath>$(NativeBinaryPrefix)$(TargetName).so</RelativePath>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</ResolvedFileToPublish>
<FileWrites Include="$(_AndroidNativeAotSharedLibrary)" />
<FileWrites Include="$(NativeIntermediateOutputPath)sections.ld" />
</ItemGroup>
</Target>
<!--
dotnet/runtime#125629 moved the NativeAOT entry point from ComputeLinkedFilesToPublish
(AfterTargets="ComputeResolvedFilesToPublishList") to NativeCompile (an SDK Publish hook).
Android uses `dotnet build` not `dotnet publish`, so NativeCompile never fires.
Restore the old scheduling so NativeCompile runs after ComputeResolvedFilesToPublishList
in the inner per-RID build.
-->
<Target Name="_AndroidRunNativeCompile"
AfterTargets="ComputeResolvedFilesToPublishList"
DependsOnTargets="_PreTrimmingFixLegacyDesignerUpdateItems;NativeCompile" />
<Target Name="_AndroidFixNativeLibraryFileName" AfterTargets="ComputeFilesToPublish">
<ItemGroup>
<!-- Fix paths to contain lib-prefix -->
<ResolvedFileToPublish Update="@(ResolvedFileToPublish)" ArchiveFileName="lib%(FileName)%(Extension)" Condition=" '%(Filename)%(Extension)' == '$(TargetName).so' " />
</ItemGroup>
</Target>
</Project>