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
[Xamarin.Android.Build.Tasks] filter @(ReferencePath) for MonoAndroid assemblies
We have a couple MSBuild targets that need to only operate on
`MonoAndroid` assemblies:
* `_BuildAdditionalResourcesCache` is the precursor to
Xamarin.Build.Download
* `_ResolveLibraryProjectImports` unzips
`__AndroidLibrariesProjects__.zip`, .jar/.aar files, etc.
Both of these targets all looking at *all* assemblies, so we could
make a new item group `@(_MonoAndroidReferencePath)` and use this
instead. This would both allow the tasks inside these targets to
operate on less assemblies. It would also allow them to skip for
changes in NetStandard projects.
I added a new `<FilterAssemblies/>` MSBuild task to filter based on
the presence of this attribute in an assembly:
[assembly: System.Runtime.Versioning.TargetFrameworkAttribute ("MonoAndroid,Version=v8.1")]
MSBuild/Roslyn populate this attribute based on the
`$(TargetFrameworkIdentifier)` of the project.
~~ Results ~~
I tested the Xamarin.Forms project in this repo.
Initial build:
Before:
78 ms _BuildAdditionalResourcesCache 1 calls
1678 ms _ResolveLibraryProjectImports 1 calls
After:
47 ms FilterAssemblies 1 calls
23 ms _BuildAdditionalResourcesCache 1 calls
1120 ms _ResolveLibraryProjectImports 1 calls
Incremental build with XAML change:
Before:
62 ms _BuildAdditionalResourcesCache 1 calls
300 ms _ResolveLibraryProjectImports 1 calls
After:
62 ms FilterAssemblies 1 calls
0 ms _BuildAdditionalResourcesCache 1 calls
16 ms _ResolveLibraryProjectImports 1 calls
Note that during the incremental build, since only a NetStandard
assembly was updated the following targets are skipped:
_BuildAdditionalResourcesCache:
Skipping target "_BuildAdditionalResourcesCache" because all output files are up-to-date with respect to the input files.
...
_ResolveLibraryProjectImports:
Skipping target "_ResolveLibraryProjectImports" because all output files are up-to-date with respect to the input files.
Overall I would say this saves ~500ms on initial build, and ~250ms on
incremental builds.
0 commit comments