Skip to content

Commit

Permalink
[Xamarin.Android.Build.Tasks] _CreateAapt2VersionCache slow due to …
Browse files Browse the repository at this point in the history
…wildcard usage

Fixes #2121

There were a number of performace issues with `_CreateAapt2VersionCache`.
First the wildcards were processing the ENTIRE `$(IntermediateOutputPath)`!
What they should have been doing was targeting specific
directories. I.e the root of `$(IntermediateOutputPath)` and
the directories under `$(IntermediateOutputPath)\lp`.

The target did not have a Condition to stop it running if
the versions matched, so that has been added.

However, even if a target is NOT run. MSbuild will still evaluate
the `PropertyGroups` and `ItemGroups` within the targets. So we
need to add `Conditon` on the `_CompiledFlataArchive` and
`_CompiledFlataStamp` items as well.

With these in place the time when this target is skipped is down
to 1ms.
  • Loading branch information
dellis1972 committed Sep 4, 2018
1 parent c2d3681 commit 215f26c
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ Copyright (C) 2011-2012 Xamarin. All rights reserved.
<Target Name="_CreateAapt2VersionCache"
DependsOnTargets="_ReadAapt2VersionCache"
AfterTargets="_SetLatestTargetFrameworkVersion"
Condition="'$(_AndroidUseAapt2)' == 'True'"
Condition="'$(_AndroidUseAapt2)' == 'True' And '$(_Aapt2Version)' != '@(_Aapt2VersionCache)'"
>
<MakeDir Directories="$(IntermediateOutputPath)" Condition="!Exists('$(IntermediateOutputPath)')" />
<WriteLinesToFile
Expand All @@ -794,8 +794,9 @@ Copyright (C) 2011-2012 Xamarin. All rights reserved.
Overwrite="true"
/>
<ItemGroup>
<_CompiledFlataArchive Include="$(IntermediateOutputPath)\**\*.flata"/>
<_CompiledFlataStamp Include="$(IntermediateOutputPath)\**\compiled.stamp"/>
<_CompiledFlataArchive Include="$(_AndroidLibrayProjectIntermediatePath)**\*.flata" Condition="'$(_Aapt2Version)' != '@(_Aapt2VersionCache)'" />
<_CompiledFlataArchive Include="$(IntermediateOutputPath)\*.flata" Condition="'$(_Aapt2Version)' != '@(_Aapt2VersionCache)'" />
<_CompiledFlataStamp Include="$(_AndroidLibrayProjectIntermediatePath)**\compiled.stamp" Condition="'$(_Aapt2Version)' != '@(_Aapt2VersionCache)'" />
</ItemGroup>
<Delete Files="@(_CompiledFlataArchive);@(_CompiledFlataStamp)" Condition="'$(_Aapt2Version)' != '@(_Aapt2VersionCache)'" />
</Target>
Expand Down

0 comments on commit 215f26c

Please sign in to comment.