Commit f68cfc4
committed
Fix an issue with incremental builds.
We have been getting on and off reports of the following
errors in Android for quite a while now.
```
Resources/values/styles.xml(2): error APT2260: resource attr/colorPrimary (aka Microsoft.Maui:attr/colorPrimary) not found.
```
It was always very confusing as to why this was happening.
No one ever seemed to be able to figure out why these files
were deleted.
Well it turns out they were not deleted, just not included.
While building maui I came across this issue and managed to
capture a `.binlog`.
It turns out that the `_CleanMonoAndroidIntermediateDir` target
was running. And it was deleting certain files. This target was
running because `_CleanIntermediateIfNeeded` was running.
That was running because the `build.props` file had changed...
That was because the NuGet `project.assets.json` file had a new
timestamp! On an incremental build....
So it looks like NuGet sometimes touches the `project.assets.json`
file even if it does not change. We can't blame them for that as
we do similar things.
The next confusing thing and the principal cause is that the
`libraryprojectimports.cache` was being deleted, probably buy the
call to `_CleanMonoAndroidIntermediateDir`. However the
`_ResolveLibraryProjectImports.stamp` file was left in place.
This means the `_ResolveLibraryProjectImports` does NOT run.
So we end up NOT including ANY of the resource `res.zip` files when
calling `aapt2`. The `_ResolveLibraryProjectImports` target did not
include `libraryprojectimports.cache` in its `Outputs`. So if the file
did not exist, but the stamp file did the target would not run.
It is confusing because in the `_CleanMonoAndroidIntermediateDir` we delete
the `libraryprojectimports.cache` and the entire `$(IntermediateOutputPath)stamp`
directory..
So lets include `libraryprojectimports.cache` in the outputs for starters.
Then update the `_CreatePropertiesCache` target to use a hash of the
`project.assets.json` file rather than a timestamp. This way we really
only run the build if something actually changes.
One last thing is to put in a backup into `RemoveDirFixed` Task.
I was seeing the following error when building maui
```
bin/dotnet/packs/Microsoft.Android.Sdk.Darwin/34.0.113/tools/Xamarin.Android.Common.targets(2582,2): error XARDF7024: System.IO.IOException: Directory not empty : 'artifacts/obj/Controls.Maps/Debug/net8.0-android34.0/lp/'
at System.IO.FileSystem.RemoveEmptyDirectory(String fullPath, Boolean topLevel, Boolean throwWhenNotEmpty)
at System.IO.FileSystem.RemoveDirectoryRecursive(String fullPath)
at Xamarin.Android.Tasks.RemoveDirFixed.RunTask() [src/Controls/Maps/src/Controls.Maps.csproj]
```
Which is apparently something that the call `Directory.Delete("", recursive: true)`
can raise! So lets put in a backup path to try to delete the files manually.1 parent 99ba813 commit f68cfc4
File tree
4 files changed
+54
-4
lines changed- src/Xamarin.Android.Build.Tasks
- Tasks
- Tests/Xamarin.Android.Build.Tests
4 files changed
+54
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| |||
79 | 80 | | |
80 | 81 | | |
81 | 82 | | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
82 | 90 | | |
83 | 91 | | |
84 | 92 | | |
| |||
90 | 98 | | |
91 | 99 | | |
92 | 100 | | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
93 | 115 | | |
94 | 116 | | |
95 | 117 | | |
| |||
Lines changed: 22 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
108 | 113 | | |
109 | 114 | | |
110 | 115 | | |
| |||
827 | 832 | | |
828 | 833 | | |
829 | 834 | | |
| 835 | + | |
830 | 836 | | |
831 | 837 | | |
832 | 838 | | |
| |||
867 | 873 | | |
868 | 874 | | |
869 | 875 | | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
870 | 892 | | |
871 | 893 | | |
872 | 894 | | |
| |||
Lines changed: 9 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
907 | 907 | | |
908 | 908 | | |
909 | 909 | | |
910 | | - | |
| 910 | + | |
911 | 911 | | |
912 | | - | |
913 | 912 | | |
914 | 913 | | |
915 | 914 | | |
916 | 915 | | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
917 | 923 | | |
918 | 924 | | |
919 | 925 | | |
| |||
942 | 948 | | |
943 | 949 | | |
944 | 950 | | |
945 | | - | |
| 951 | + | |
946 | 952 | | |
947 | 953 | | |
948 | 954 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| |||
0 commit comments