Fix AndroidResource Incremental build issue #9592
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #9588
Adding a new Android resource to a project causes the incremental build to error with:
Resources\layout\activity_two.xml error APT2126: file not found.
This error comes from the Aapt2Compile task. It is looking for \obj\Debug\net9.0-android\res\layout\activity_two.xml but that file doesn't exist.
What was happening is the new file had the same modified date as the flag/stamp file that was used to generate it.
The user was using
copy Resources\layout\activity_main.xml Resources\layout\activity_two.xml
. So the modified date was not "new". This caused the_GenerateAndroidResourceDir
target to get skipped.What we should do is copy what we do in other places, and hash all the input files (and their destinations) into one hash.
We can then use that hash file as an input to the target. This allows us to detect when a new file is added, even if it has an old timestamp.
A unit test was added as well.