You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, we run the `<ConvertResourcesCases/>` MSBuild task for all
assemblies (on each assembly's `<ResolveLibraryProjectImports/>`
output). `<ConvertResourcesCases/>` is one of our slower tasks.
Luckily, there are some "well-known" assemblies that we could skip,
so we have decided to "whitelist" certain assemblies such as the
Android support libraries, Google Play Services, Firebase, etc.
A new `@(_AndroidAssemblySkipCases)` item group has been added, e.g.:
<_AndroidAssemblySkipCases Include="Xamarin.Android.Support.v7.AppCompat" />
<_AndroidAssemblySkipCases Include="Xamarin.Android.Support.v7.CardView" />
The `@(_AndroidAssemblySkipCases)` item group is an indicator for
`<ConvertResourcesCases/>` to just completely skip these assemblies.
Additionally, we can flat out skip `.aar` files in the same manner.
To make this work:
- Added support to put `ITaskItem` metadata in the cache file
produced by `<ResolveLibraryProjectImports/>`
- Added item metadata for `%(SkipAndroidResourceProcessing)` and
`%(OriginalFile)`.
- `<ConvertResourcesCases/>` now skips these directories and logs
`%(OriginalFile)`.
- `<CollectNonEmptyDirectories/>` needs to preserve item metadata
for `$(AndroidUseAapt2)` to take advantage of the functionality.
The results appear to be well worth the effort!
Results with `$(AndroidUseAapt2)` enabled (note this is not currently
the default):
Before:
9912 ms ConvertResourcesCases 9 calls
2219 ms ResolveLibraryProjectImports 1 calls
After:
49 ms ConvertResourcesCases 9 calls
2185 ms ResolveLibraryProjectImports 1 calls
Results with `$(AndroidUseAapt2)` disabled:
Before:
1564 ms ConvertResourcesCases 1 calls
1826 ms ResolveLibraryProjectImports 1 calls
After:
25 ms ConvertResourcesCases 1 calls
1685 ms ResolveLibraryProjectImports 1 calls
This was the Xamarin.Forms-Integration project in this repo, an
initial clean build. It is basically a "Hello World" Xamarin.Forms
project. These updated numbers are from a `Release` build of
Xamarin.Android.
Overall this will save 1-2 seconds of `<ConvertResourcesCases/>` for
default projects. This MSBuild task runs on an initial build or
incremental builds when Android resources have changed. I have gotten
slightly different numbers on the difference, each time I've compared.
There does not appear to be any noticeable slowdown in
`<ResolveLibraryProjectImports/>` due to the changes.
Log.LogDebugMessage($"Skipping: `{dir.ItemSpec}` via `{ResolveLibraryProjectImports.SkipAndroidResourceProcessing}`, original file: `{originalFile}`...");
//Skipping: `obj\Debug\lp\5\jl\res` via `SkipAndroidResourceProcessing`, original file: `bin\TestDebug\temp\packages\Xamarin.Android.Support.Compat.27.0.2.1\lib\MonoAndroid81\Xamarin.Android.Support.Compat.dll`...
83
+
skipped.Add(line);
84
+
}
85
+
}
86
+
87
+
varresources=new[]{
88
+
Path.Combine("layout","main.xml"),
89
+
Path.Combine("layout","tabbar.xml"),
90
+
Path.Combine("layout","toolbar.xml"),
91
+
Path.Combine("values","colors.xml"),
92
+
Path.Combine("values","strings.xml"),
93
+
Path.Combine("values","styles.xml"),
94
+
};
95
+
foreach(varresourceinresources){
96
+
Assert.IsTrue(StringAssertEx.ContainsText(processed,resource),$"`{target}` should process `{resource}`.");
97
+
}
98
+
99
+
varfiles=new[]{
100
+
"Xamarin.Android.Support.Compat.dll",
101
+
"Xamarin.Android.Support.Design.dll",
102
+
"Xamarin.Android.Support.Media.Compat.dll",
103
+
"Xamarin.Android.Support.Transition.dll",
104
+
"Xamarin.Android.Support.v4.dll",
105
+
"Xamarin.Android.Support.v7.AppCompat.dll",
106
+
"Xamarin.Android.Support.v7.CardView.dll",
107
+
"Xamarin.Android.Support.v7.MediaRouter.dll",
108
+
"Xamarin.Android.Support.v7.RecyclerView.dll",
109
+
"material-menu-1.1.0.aar",
110
+
};
111
+
foreach(varfileinskipped){
112
+
Assert.IsTrue(StringAssertEx.ContainsText(skipped,file),$"`{target}` should skip `{file}`.");
0 commit comments