-
Notifications
You must be signed in to change notification settings - Fork 566
Expand file tree
/
Copy pathMicrosoft.Android.Sdk.AssemblyResolution.targets
More file actions
292 lines (272 loc) · 15.8 KB
/
Microsoft.Android.Sdk.AssemblyResolution.targets
File metadata and controls
292 lines (272 loc) · 15.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
<!--
***********************************************************************************************
Microsoft.Android.Sdk.AssemblyResolution.targets
This file contains the .NET 5-specific implementation for the
_ResolveAssemblies MSBuild target.
***********************************************************************************************
-->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="Xamarin.Android.Tasks.ProcessAssemblies" AssemblyFile="$(_XamarinAndroidBuildTasksAssembly)" />
<UsingTask TaskName="Xamarin.Android.Tasks.ProcessNativeLibraries" AssemblyFile="$(_XamarinAndroidBuildTasksAssembly)" />
<UsingTask TaskName="Xamarin.Android.Tasks.ProcessRuntimePackLibraryDirectories" AssemblyFile="$(_XamarinAndroidBuildTasksAssembly)" />
<UsingTask TaskName="Xamarin.Android.Tasks.StripNativeLibraries" AssemblyFile="$(_XamarinAndroidBuildTasksAssembly)" />
<PropertyGroup Condition=" '$(_ComputeFilesToPublishForRuntimeIdentifiers)' == 'true' ">
<OutputPath Condition=" '$(_OuterOutputPath)' != '' ">$(_OuterOutputPath)</OutputPath>
<OutDir Condition=" '$(_OuterOutputPath)' != '' ">$(_OuterOutputPath)</OutDir>
<PublishDir>$(OutputPath)</PublishDir>
<BuildDependsOn>_RemoveLegacyDesigner;$(BuildDependsOn)</BuildDependsOn>
<!-- We don't want IncrementalClean to run here, or files get deleted -->
<CoreBuildDependsOn>
$([MSBuild]::Unescape($(CoreBuildDependsOn.Replace('IncrementalClean;', ''))))
</CoreBuildDependsOn>
<CompileDependsOn>
AndroidPrepareForBuild;
$(CompileDependsOn);
</CompileDependsOn>
</PropertyGroup>
<PropertyGroup>
<!-- When marshal methods are enabled, AOT needs to run after the GenerateJavaStubs task -->
<_RunAotMaybe Condition=" '$(_AndroidUseMarshalMethods)' != 'True' ">_AndroidAot</_RunAotMaybe>
</PropertyGroup>
<Target Name="_ComputeFilesToPublishForRuntimeIdentifiers"
DependsOnTargets="BuildOnlySettings;_FixupIntermediateAssembly;ResolveReferences;ComputeFilesToPublish;$(_RunAotMaybe)"
Returns="@(ResolvedFileToPublish)">
<ItemGroup>
<ResolvedFileToPublish Remove="@(_SourceItemsToCopyToPublishDirectory)" />
<ResolvedFileToPublish
Condition=" '%(ResolvedFileToPublish.RuntimeIdentifier)' == '' "
Update="@(ResolvedFileToPublish)"
RuntimeIdentifier="$(RuntimeIdentifier)"
/>
</ItemGroup>
<!-- In .NET 11+, multiple targets (ILLink, NativeAOT runtime, Android) may independently
add the same assembly to ResolvedFileToPublish. Deduplicate before returning to the
outer build, which does not use Distinct() since items from different RIDs must be kept. -->
<RemoveDuplicates Condition=" '$(_AndroidRuntime)' == 'NativeAOT' " Inputs="@(ResolvedFileToPublish)">
<Output TaskParameter="Filtered" ItemName="_DeduplicatedResolvedFileToPublish" />
</RemoveDuplicates>
<ItemGroup Condition=" '$(_AndroidRuntime)' == 'NativeAOT' ">
<ResolvedFileToPublish Remove="@(ResolvedFileToPublish)" />
<ResolvedFileToPublish Include="@(_DeduplicatedResolvedFileToPublish)" />
</ItemGroup>
<AndroidWarning
Code="XA1024"
ResourceName="XA1024"
FormatArguments="%(_SourceItemsToCopyToPublishDirectory.Identity)"
Condition=" '%(Extension)' == '.config' "
/>
</Target>
<Target Name="_FixupIntermediateAssembly" Condition=" '$(_OuterIntermediateAssembly)' != '' ">
<ItemGroup>
<IntermediateAssembly Remove="@(IntermediateAssembly)" />
<IntermediateAssembly Include="$(_OuterIntermediateAssembly)" />
</ItemGroup>
<ItemGroup Condition=" '$(AndroidUseDesignerAssembly)' == 'True' ">
<ReferenceCopyLocalPaths Include="$(_GenerateResourceDesignerAssemblyOutput)">
<PostprocessAssembly>True</PostprocessAssembly>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
<IsTrimmable>false</IsTrimmable>
<RuntimeIdentifier>android</RuntimeIdentifier>
</ReferenceCopyLocalPaths>
</ItemGroup>
<ItemGroup Condition=" '@(_DebugSymbolsIntermediatePath->Count())' != '0' ">
<_DebugSymbolsIntermediatePath Remove="@(_DebugSymbolsIntermediatePath)" />
<_DebugSymbolsIntermediatePath Include="$([System.IO.Path]::ChangeExtension ($(_OuterIntermediateAssembly), '.pdb'))" />
</ItemGroup>
</Target>
<Target Name="_ResolveAssemblies" DependsOnTargets="_AndroidConfigureHotReloadEnvironment">
<ItemGroup>
<_RIDs Include="$(RuntimeIdentifier)" Condition=" '$(RuntimeIdentifiers)' == '' " />
<_RIDs Include="$(RuntimeIdentifiers)" Condition=" '$(RuntimeIdentifiers)' != '' " />
</ItemGroup>
<PropertyGroup>
<_AdditionalProperties>
_ComputeFilesToPublishForRuntimeIdentifiers=true
;SelfContained=true
;DesignTimeBuild=$(DesignTimeBuild)
;AppendRuntimeIdentifierToOutputPath=true
;ResolveAssemblyReferencesFindRelatedSatellites=false
;SkipCompilerExecution=true
;_OuterIntermediateAssembly=@(IntermediateAssembly)
;_OuterIntermediateSatelliteAssembliesWithTargetPath=@(IntermediateSatelliteAssembliesWithTargetPath)
;_OuterOutputPath=$(OutputPath)
;_OuterIntermediateOutputPath=$(IntermediateOutputPath)
;_OuterCustomViewMapFile=$(_CustomViewMapFile)
;_AndroidNdkDirectory=$(_AndroidNdkDirectory)
</_AdditionalProperties>
<_AndroidBuildRuntimeIdentifiersInParallel Condition=" '$(_AndroidBuildRuntimeIdentifiersInParallel)' == '' ">true</_AndroidBuildRuntimeIdentifiersInParallel>
</PropertyGroup>
<ItemGroup>
<_ProjectToBuild Include="$(MSBuildProjectFile)" AdditionalProperties="RuntimeIdentifier=%(_RIDs.Identity);$(_AdditionalProperties)" />
</ItemGroup>
<MSBuild
Condition=" '$(DesignTimeBuild)' != 'true' "
Projects="@(_ProjectToBuild)"
BuildInParallel="$(_AndroidBuildRuntimeIdentifiersInParallel)"
Targets="_ComputeFilesToPublishForRuntimeIdentifiers">
<Output TaskParameter="TargetOutputs" ItemName="ResolvedFileToPublish" />
</MSBuild>
<!-- This must be done as early as possible, so the runtime libraries location is known to all
the tasks that need it and so that the shared library files that are never to be packaged
are never taken into consideration in any context.
-->
<ProcessRuntimePackLibraryDirectories
Condition=" '$(_AndroidRuntime)' != 'NativeAOT' "
ResolvedFilesToPublish="@(ResolvedFileToPublish)">
<Output TaskParameter="RuntimePackLibraryDirectories" ItemName="_RuntimePackLibraryDirectory" />
<Output TaskParameter="NativeLibrariesToRemove" ItemName="_NativeLibraryToRemove" />
</ProcessRuntimePackLibraryDirectories>
<ItemGroup>
<ResolvedFileToPublish Include="$(_AndroidHotReloadAgentAssemblyPath)" Condition="Exists('$(_AndroidHotReloadAgentAssemblyPath)')" RuntimeIdentifier="%(_RIDs.Identity)" />
<ResolvedFileToPublish Remove="@(_NativeLibraryToRemove)" />
</ItemGroup>
<!-- Properties produced by the inner build in Microsoft.Android.Sdk.ILLink.targets -->
<PropertyGroup>
<_InnerIntermediateOutputPath Condition=" '$(RuntimeIdentifier)' == '' ">$(IntermediateOutputPath)%(_RIDs.Identity)\</_InnerIntermediateOutputPath>
<_InnerIntermediateOutputPath Condition=" '$(RuntimeIdentifier)' != '' ">$(IntermediateOutputPath)</_InnerIntermediateOutputPath>
<_ProguardProjectConfiguration Condition=" '$(AndroidLinkTool)' != '' ">$(_InnerIntermediateOutputPath)proguard\proguard_project_references.cfg</_ProguardProjectConfiguration>
<_AndroidLinkFlag Condition=" '$(RuntimeIdentifier)' == '' " >$(_InnerIntermediateOutputPath)link.flag</_AndroidLinkFlag>
</PropertyGroup>
<ItemGroup>
<_ResolvedAssemblyFiles Include="@(ResolvedFileToPublish)" Condition=" '%(ResolvedFileToPublish.Extension)' == '.dll' " />
<_ResolvedSymbolFiles Include="@(ResolvedFileToPublish)" Condition=" '%(ResolvedFileToPublish.Extension)' == '.pdb' " />
<_ResolvedJavaLibraries Include="@(ResolvedFileToPublish)" Condition=" '%(ResolvedFileToPublish.Extension)' == '.jar' " />
</ItemGroup>
<!-- All assemblies must be per-RID, thus no `->Distinct()` on `InputAssemblies` or `ResolvedSymbols` items -->
<ProcessAssemblies
RuntimeIdentifiers="@(_RIDs)"
DesignTimeBuild="$(DesignTimeBuild)"
InputAssemblies="@(_ResolvedAssemblyFiles)"
InputJavaLibraries="@(_ResolvedJavaLibraries->Distinct())"
ResolvedSymbols="@(_ResolvedSymbolFiles)"
AndroidIncludeDebugSymbols="$(AndroidIncludeDebugSymbols)"
PublishTrimmed="$(PublishTrimmed)">
<Output TaskParameter="OutputAssemblies" ItemName="_ProcessedAssemblies" />
<Output TaskParameter="OutputJavaLibraries" ItemName="AndroidJavaLibrary" />
<Output TaskParameter="ResolvedSymbols" ItemName="ResolvedSymbols" />
<Output TaskParameter="ShrunkAssemblies" ItemName="_ProcessedShrunkAssemblies" />
</ProcessAssemblies>
<AppendCustomMetadataToItemGroup
Inputs="@(_ProcessedAssemblies)"
MetaDataItems="@(AndroidCustomMetaDataForReferences)">
<Output TaskParameter="Output" ItemName="ResolvedAssemblies" />
</AppendCustomMetadataToItemGroup>
<AppendCustomMetadataToItemGroup
Inputs="@(_ProcessedShrunkAssemblies)"
MetaDataItems="@(AndroidCustomMetaDataForReferences)">
<Output TaskParameter="Output" ItemName="_ShrunkAssemblies" />
</AppendCustomMetadataToItemGroup>
<ItemGroup>
<ResolvedFrameworkAssemblies
Include="@(ResolvedAssemblies)"
Condition=" '%(ResolvedAssemblies.FrameworkAssembly)' == 'true' "
/>
<ResolvedUserAssemblies
Include="@(ResolvedAssemblies)"
Condition=" '%(ResolvedAssemblies.FrameworkAssembly)' != 'true' "
/>
</ItemGroup>
<Hash ItemsToHash="@(ResolvedAssemblies)">
<Output TaskParameter="HashResult" PropertyName="_ResolvedUserAssembliesHash" />
</Hash>
<WriteLinesToFile
File="$(_ResolvedUserAssembliesHashFile)"
Lines="$(_ResolvedUserAssembliesHash)"
Overwrite="true"
WriteOnlyWhenDifferent="true"
/>
<ItemGroup>
<FileWrites Include="$(_ResolvedUserAssembliesHashFile)" />
</ItemGroup>
</Target>
<PropertyGroup>
<_PrepareAssembliesDependsOnTargets>
_ResolveAssemblies;
_ResolveSatellitePaths;
_CreatePackageWorkspace;
_LinkAssemblies;
_AfterILLinkAdditionalSteps;
</_PrepareAssembliesDependsOnTargets>
</PropertyGroup>
<Target Name="_PrepareAssemblies"
DependsOnTargets="$(_PrepareAssembliesDependsOnTargets)">
<ItemGroup>
<_ResolvedAssemblies Include="@(ResolvedAssemblies)" />
<_ResolvedUserAssemblies Include="@(ResolvedUserAssemblies)" />
<_ResolvedFrameworkAssemblies Include="@(ResolvedFrameworkAssemblies)" />
<_ResolvedSymbols Include="@(ResolvedSymbols)" />
</ItemGroup>
<ItemGroup Condition=" '$(PublishTrimmed)' != 'true' ">
<_ShrunkAssemblies Include="@(_ResolvedAssemblies)" />
<_ShrunkUserAssemblies Include="@(_ResolvedUserAssemblies)" />
<_ShrunkFrameworkAssemblies Include="@(_ResolvedFrameworkAssemblies)" />
</ItemGroup>
<ItemGroup Condition=" '$(PublishTrimmed)' == 'true' ">
<_ShrunkFrameworkAssemblies
Include="@(_ShrunkAssemblies)"
Condition=" '%(_ShrunkAssemblies.FrameworkAssembly)' == 'true' "
/>
<_ShrunkUserAssemblies
Include="@(_ShrunkAssemblies)"
Condition=" '%(_ShrunkAssemblies.FrameworkAssembly)' != 'true' "
/>
</ItemGroup>
<ItemGroup>
<_ResolvedUserMonoAndroidAssemblies
Include="@(_ResolvedUserAssemblies)"
Condition=" '%(_ResolvedUserAssemblies.TargetFrameworkIdentifier)' == 'MonoAndroid' Or '%(_ResolvedUserAssemblies.HasMonoAndroidReference)' == 'True' "
/>
</ItemGroup>
</Target>
<Target Name="_IncludeNativeSystemLibraries">
<PropertyGroup>
<_AndroidIncludeSystemGlobalizationNative Condition=" '$(_AndroidIncludeSystemGlobalizationNative)' == '' ">true</_AndroidIncludeSystemGlobalizationNative>
<_AndroidEnableNativeStackTracing Condition=" '$(_AndroidEnableNativeStackTracing)' == ''">false</_AndroidEnableNativeStackTracing>
</PropertyGroup>
<ItemGroup>
<_ResolvedNativeLibraries Include="@(ResolvedFileToPublish)" Condition=" '%(ResolvedFileToPublish.Extension)' == '.so' " />
<!-- Exclude native libraries from non-Android RIDs (e.g. runtimes/linux-x64/native/).
The .NET SDK sets RuntimeIdentifier metadata to the current Android RID on all
ResolvedFileToPublish items, causing non-Android .so files to pass ABI checks
downstream. Check the file path for non-Android runtimes/ directories.
Note: both 'android-*' and 'linux-bionic-*' RIDs are valid Android targets. -->
<_ResolvedNativeLibraries Remove="@(_ResolvedNativeLibraries)"
Condition=" $([System.String]::new('%(Identity)').Replace('\','/').Contains('/runtimes/')) And
!$([System.String]::new('%(Identity)').Replace('\','/').Contains('/runtimes/android')) And
!$([System.String]::new('%(Identity)').Replace('\','/').Contains('/runtimes/linux-bionic')) " />
</ItemGroup>
<ItemGroup>
<_MonoComponent Condition=" '$(AndroidEnableProfiler)' == 'true' " Include="diagnostics_tracing" />
<_MonoComponent Condition=" '$(AndroidUseInterpreter)' == 'true' " Include="hot_reload" />
<_MonoComponent Condition=" '$(AndroidIncludeDebugSymbols)' == 'true' " Include="debugger" />
<_MonoComponent Condition=" '$(_AndroidExcludeMarshalIlgenComponent)' != 'true' " Include="marshal-ilgen" />
<!-- Filename without extension -->
<_ExcludedNativeLibraries Condition=" '$(_AndroidIncludeSystemGlobalizationNative)' != 'true' " Include="libSystem.Globalization.Native" />
<_ExcludedNativeLibraries Condition=" '$(_AndroidEnableNativeStackTracing)' != 'true' " Include="libxamarin-native-tracing" />
<_ExcludedNativeLibraries Condition=" '$(_AndroidRuntime)' == 'MonoVM' Or '$(_AndroidRuntime)' == '' " Include="libnet-android.debug" />
<_ExcludedNativeLibraries Condition=" '$(_AndroidRuntime)' == 'MonoVM' Or '$(_AndroidRuntime)' == '' " Include="libnet-android.release" />
<_ExcludedNativeLibraries Condition=" '$(_AndroidRuntime)' == 'CoreCLR' " Include="libmono-android.debug" />
<_ExcludedNativeLibraries Condition=" '$(_AndroidRuntime)' == 'CoreCLR' " Include="libmono-android.release" />
</ItemGroup>
<!-- Let's keep the item group close to the task that uses them, the list is irrelevant for
anything else. The group MUST contain only shared libraries from the runtime pack.
DO NOT modify the group unless you're absolutely sure what you're doing -->
<ItemGroup Condition=" '$(_AndroidRuntime)' == 'CoreCLR' " >
<_KnownRuntimeNativeLibrary Include="libSystem.Globalization.Native.so" />
<_KnownRuntimeNativeLibrary Include="libSystem.IO.Compression.Native.so" />
<_KnownRuntimeNativeLibrary Include="libSystem.Native.so" />
<_KnownRuntimeNativeLibrary Include="libSystem.Security.Cryptography.Native.Android.so" />
<_KnownRuntimeNativeLibrary Include="libclrjit.so" />
<_KnownRuntimeNativeLibrary Include="libcorclr.so" />
</ItemGroup>
<ProcessNativeLibraries
NativeRuntimeLinking="$(_AndroidEnableNativeRuntimeLinking)"
InputLibraries="@(_ResolvedNativeLibraries)"
ExcludedLibraries="@(_ExcludedNativeLibraries)"
Components="@(_MonoComponent->Distinct())"
IncludeDebugSymbols="$(AndroidIncludeDebugSymbols)"
KnownRuntimeNativeLibraries="@(_KnownRuntimeNativeLibrary)">
<Output TaskParameter="OutputLibraries" ItemName="FrameworkNativeLibrary" />
</ProcessNativeLibraries>
</Target>
</Project>