Commit 87bb898
[Xamarin.Android.Build.Tasks] prevent _BuildLibraryProjectImportsCache always running (#2132)
When testing a build with no changes, I started noticing:
Building target "_BuildLibraryImportsCache" completely.
Input file "App7\bin\Debug\netstandard2.0\App7.dll" is newer than output file "obj\Debug\90\libraryimports.cache".
What was weird, is that earlier in the build log:
Did not copy from file "bin\Debug\netstandard2.0\App7.dll" to file "bin\Debug\App7.dll" because the "SkipUnchangedFiles" parameter was set to "true" in the project and the files' sizes and timestamps match.
So the NetStandard assembly didn't change.
When I looked at these files:
8/31/2018 11:02 AM App7.dll
8/31/2018 10:09 AM resourcepaths.cache
Weird? It looks like `resourcepaths.cache`'s timestamp needs to be
updated?
Then I looked and noticed that the timestamp of `resourcepaths.cache`
would only be updated if the XML changed.
My *first* attempt to fix this:
- I made `XDocumentExtensions.SaveIfChanged` return a `bool`
indicating if the file changed.
- I changed the `GetImportedLibraries` task so that it would update
the timestamp in cases where the file didn't change.
Unfortunately, that made `_UpdateAndroidResgen` run all the time,
which would be even worse!
So my *second* attempt was much better:
- Add a `$(_AndroidLibraryImportsCache).stamp` file, to use as the
`Outputs` of `_BuildLibraryImportsCache`.
- This file's timestamp can operate independently of
`$(_AndroidLibraryImportsCache)`
`_BuildLibraryImportsCache` now builds incrementally and gets skipped
properly:
Skipping target "_BuildLibraryImportsCache" because all output files are up-to-date with respect to the input files.
It seems to me this problem was always occurring on builds with no
changes. So this will likely help any incremental build.
Before this change:
146 ms _BuildLibraryImportsCache 1 calls
Total time: 2.824s
After this change:
4 ms _BuildLibraryImportsCache 1 calls
Total time: 2.698s
I also updated an existing test to make sure the
`_BuildLibraryImportsCache` target isn't running all the time.1 parent 63b5d6d commit 87bb898
File tree
2 files changed
+7
-1
lines changed- src/Xamarin.Android.Build.Tasks
- Tests/Xamarin.Android.Build.Tests
2 files changed
+7
-1
lines changedLines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
318 | 318 | | |
319 | 319 | | |
320 | 320 | | |
| 321 | + | |
321 | 322 | | |
322 | 323 | | |
323 | 324 | | |
| |||
Lines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1447 | 1447 | | |
1448 | 1448 | | |
1449 | 1449 | | |
1450 | | - | |
| 1450 | + | |
1451 | 1451 | | |
1452 | 1452 | | |
1453 | 1453 | | |
| 1454 | + | |
| 1455 | + | |
| 1456 | + | |
| 1457 | + | |
1454 | 1458 | | |
1455 | 1459 | | |
1456 | 1460 | | |
| |||
3071 | 3075 | | |
3072 | 3076 | | |
3073 | 3077 | | |
| 3078 | + | |
3074 | 3079 | | |
3075 | 3080 | | |
3076 | 3081 | | |
| |||
0 commit comments