1
1
using System ;
2
2
using System . Collections . Generic ;
3
3
using System . IO ;
4
+ using System . Linq ;
4
5
5
6
using Microsoft . Android . Build . Tasks ;
6
7
using Microsoft . Build . Framework ;
@@ -14,37 +15,28 @@ public class CreateEmbeddedAssemblyStore : AndroidTask
14
15
public override string TaskPrefix => "CEAS" ;
15
16
16
17
[ Required ]
17
- public string AndroidBinUtilsDirectory { get ; set ; }
18
+ public string AndroidBinUtilsDirectory { get ; set ; } = "" ;
18
19
19
20
[ Required ]
20
- public string AppSharedLibrariesDir { get ; set ; }
21
+ public string AppSharedLibrariesDir { get ; set ; } = "" ;
21
22
22
23
[ Required ]
23
- public string AssemblySourcesDir { get ; set ; }
24
-
25
- [ Required ]
26
- public string CompressedAssembliesDir { get ; set ; }
24
+ public string AssemblySourcesDir { get ; set ; } = "" ;
27
25
28
26
[ Required ]
29
27
public bool AssemblyStoreEmbeddedInRuntime { get ; set ; }
30
28
31
29
[ Required ]
32
- public bool Debug { get ; set ; }
33
-
34
- [ Required ]
35
- public bool EnableCompression { get ; set ; }
30
+ public bool IncludeDebugSymbols { get ; set ; }
36
31
37
32
[ Required ]
38
- public string ProjectFullPath { get ; set ; }
33
+ public ITaskItem [ ] ResolvedUserAssemblies { get ; set ; } = [ ] ;
39
34
40
35
[ Required ]
41
- public ITaskItem [ ] ResolvedUserAssemblies { get ; set ; }
36
+ public ITaskItem [ ] ResolvedFrameworkAssemblies { get ; set ; } = [ ] ;
42
37
43
38
[ Required ]
44
- public ITaskItem [ ] ResolvedFrameworkAssemblies { get ; set ; }
45
-
46
- [ Required ]
47
- public string [ ] SupportedAbis { get ; set ; }
39
+ public string [ ] SupportedAbis { get ; set ; } = [ ] ;
48
40
49
41
public override bool RunTask ( )
50
42
{
@@ -70,27 +62,14 @@ public override bool RunTask ()
70
62
71
63
bool EmbedAssemblyStore ( )
72
64
{
73
- bool compress = ! Debug && EnableCompression ;
74
- IDictionary < AndroidTargetArch , Dictionary < string , CompressedAssemblyInfo > > ? compressedAssembliesInfo = null ;
75
-
76
- if ( compress ) {
77
- string key = CompressedAssemblyInfo . GetKey ( ProjectFullPath ) ;
78
- Log . LogDebugMessage ( $ "[{ TaskPrefix } ] Retrieving assembly compression info with key '{ key } '") ;
79
- compressedAssembliesInfo = BuildEngine4 . GetRegisteredTaskObjectAssemblyLocal < IDictionary < AndroidTargetArch , Dictionary < string , CompressedAssemblyInfo > > > ( key , RegisteredTaskObjectLifetime . Build ) ;
80
- if ( compressedAssembliesInfo == null ) {
81
- throw new InvalidOperationException ( $ "Assembly compression info not found for key '{ key } '. Compression will not be performed.") ;
82
- }
83
- }
84
-
85
- var storeBuilder = new AssemblyStoreBuilder ( Log ) ;
65
+ var assemblies = ResolvedFrameworkAssemblies . Concat ( ResolvedUserAssemblies ) . Where ( asm => ! ( AssemblyPackagingHelper . ShouldSkipAssembly ( Log , asm ) ) ) ;
66
+ var assemblyStorePaths = AssemblyPackagingHelper . CreateAssemblyStore (
67
+ Log , assemblies ,
68
+ Path . Combine ( AppSharedLibrariesDir , "embedded" ) ,
69
+ SupportedAbis ,
70
+ IncludeDebugSymbols
71
+ ) ;
86
72
87
- // Add user assemblies
88
- AssemblyPackagingHelper . AddAssembliesFromCollection ( Log , SupportedAbis , ResolvedUserAssemblies , DoAddAssembliesFromArchCollection ) ;
89
-
90
- // Add framework assemblies
91
- AssemblyPackagingHelper . AddAssembliesFromCollection ( Log , SupportedAbis , ResolvedFrameworkAssemblies , DoAddAssembliesFromArchCollection ) ;
92
-
93
- Dictionary < AndroidTargetArch , string > assemblyStorePaths = storeBuilder . Generate ( Path . Combine ( AppSharedLibrariesDir , "embedded" ) ) ;
94
73
foreach ( var kvp in assemblyStorePaths ) {
95
74
string abi = MonoAndroidHelper . ArchToAbi ( kvp . Key ) ;
96
75
string inputFile = kvp . Value ;
@@ -107,21 +86,5 @@ bool EmbedAssemblyStore ()
107
86
}
108
87
109
88
return ! Log . HasLoggedErrors ;
110
-
111
- void DoAddAssembliesFromArchCollection ( TaskLoggingHelper log , AndroidTargetArch arch , ITaskItem assembly )
112
- {
113
- string sourcePath = CompressAssembly ( assembly ) ;
114
- storeBuilder . AddAssembly ( sourcePath , assembly , includeDebugSymbols : Debug ) ;
115
- return ;
116
- }
117
-
118
- string CompressAssembly ( ITaskItem assembly )
119
- {
120
- if ( ! compress ) {
121
- return assembly . ItemSpec ;
122
- }
123
-
124
- return AssemblyCompression . Compress ( Log , assembly , compressedAssembliesInfo , CompressedAssembliesDir ) ;
125
- }
126
89
}
127
90
}
0 commit comments