Uh oh!
There was an error while loading. Please reload this page.
Add _AndroidLibraryProjectImportsCache to FileWrites - #7780
Conversation
jonathanpeppers
left a comment
There was a problem hiding this comment.
Is there a way to test? Maybe we could delete $(_AndroidLibraryProjectImportsCache) in a test and do an incremental build?
dellis1972
commented
Feb 8, 2023
Not sure that would help in this senario. Deleting the file manually in a test would just cause the issue, once you get into that situation I'm not sure there is a way out of it. We could change the Outputs of |
dellis1972
commented
Feb 8, 2023
This PR is more about stopping it happening in the first place, rather than recover from I guess. |
499bf66 to
255fe2bCompare* main: [Xamarin.Android.Build.Tasks] FileWrites&libraryprojectimports.cache (dotnet#7780) Bump to dotnet/installer@d25a3bb 8.0.100-preview.2.23105.6 (dotnet#7769)
* main: [tests] Bump NUnit versions to latest (dotnet#7802) [Microsoft.Android.Sdk.ILLink] target `net7.0` temporarily (dotnet#7803) [tests] `InstallAndroidDependenciesTest` can use `platform-tools` 34.0.0 (dotnet#7800) Bump to xamarin/Java.Interop/main@9e0a469 (dotnet#7797) [Xamarin.Android.Build.Tasks] FileWrites&libraryprojectimports.cache (dotnet#7780) Bump to dotnet/installer@d25a3bb 8.0.100-preview.2.23105.6 (dotnet#7769) [lgtm] Fix LGTM-reported issues (dotnet#1074) [ci] Report issues in the API docs build log (dotnet#7784)
* main: [tests] Bump NUnit versions to latest (dotnet#7802) [Microsoft.Android.Sdk.ILLink] target `net7.0` temporarily (dotnet#7803) [tests] `InstallAndroidDependenciesTest` can use `platform-tools` 34.0.0 (dotnet#7800) Bump to xamarin/Java.Interop/main@9e0a469 (dotnet#7797) [Xamarin.Android.Build.Tasks] FileWrites&libraryprojectimports.cache (dotnet#7780) Bump to dotnet/installer@d25a3bb 8.0.100-preview.2.23105.6 (dotnet#7769)
* main: Add Unit Test for testOnly apps (dotnet#7637) [build] Only build the latest API level (dotnet#7786) [Xamarin.Android.Build.Tasks] Improve aapt2+file not found handling (dotnet#7644) [MSBuildDeviceIntegration] Fix duplicated test parameter (dotnet#7809) [tests] Bump NUnit versions to latest (dotnet#7802) [Microsoft.Android.Sdk.ILLink] target `net7.0` temporarily (dotnet#7803) [tests] `InstallAndroidDependenciesTest` can use `platform-tools` 34.0.0 (dotnet#7800) Bump to xamarin/Java.Interop/main@9e0a469 (dotnet#7797) [Xamarin.Android.Build.Tasks] FileWrites&libraryprojectimports.cache (dotnet#7780) Bump to dotnet/installer@d25a3bb 8.0.100-preview.2.23105.6 (dotnet#7769)
* main: Add Unit Test for testOnly apps (dotnet#7637) [build] Only build the latest API level (dotnet#7786) [Xamarin.Android.Build.Tasks] Improve aapt2+file not found handling (dotnet#7644) [MSBuildDeviceIntegration] Fix duplicated test parameter (dotnet#7809) [tests] Bump NUnit versions to latest (dotnet#7802) [Microsoft.Android.Sdk.ILLink] target `net7.0` temporarily (dotnet#7803) [tests] `InstallAndroidDependenciesTest` can use `platform-tools` 34.0.0 (dotnet#7800) Bump to xamarin/Java.Interop/main@9e0a469 (dotnet#7797) [Xamarin.Android.Build.Tasks] FileWrites&libraryprojectimports.cache (dotnet#7780) Bump to dotnet/installer@d25a3bb 8.0.100-preview.2.23105.6 (dotnet#7769) [lgtm] Fix LGTM-reported issues (dotnet#1074) [ci] Report issues in the API docs build log (dotnet#7784)
…7780) On occasion we see the following error when building a Maui app: MyMauiApp/Platforms/Android/AndroidManifest.xml : error APT2260: resource style/Maui.SplashTheme (aka com.companyname.mymauiapp:style/Maui.SplashTheme) not found. Looking in detail at the build log we notice that *none* of the resources in the `$(IntermediateOutputPath)\lp` folder are being included in the call to `aapt2`. Looking further we see: Skipping target "_ResolveLibraryProjectImports" because all output files are up-to-date with respect to the input files. … Task "ReadLibraryProjectImportsCache" (TaskId:184) Task Parameter:CacheFile=obj/Debug/net7.0-android/libraryprojectimports.cache (TaskId:184) Task ReadLibraryProjectImportsCache (TaskId:184) CacheFile: obj/Debug/net7.0-android/libraryprojectimports.cache (TaskId:184) obj/Debug/net7.0-android/libraryprojectimports.cache does not exist. No Project Library Imports found (TaskId:184) Done executing task "ReadLibraryProjectImportsCache". (TaskId:184) In this case it seems that the `.cache` file which stores the list of resource directories was created, but was then deleted later on! A search of our build system shows that `libraryprojectimports.cache` was never added to the `@(FileWrites)` ItemGroup. As a result `libraryprojectimports.cache` gets deleted, but the `.stamp` file which controls `_ResolveLibraryProjectImports` is left in place. We end up in a situation where the target which generates the cache will *never* run again because its stamp file is present. Only a full Clean will fix this issue. Fix this situation by updating the `_ResolveLibraryProjectImports` target to add `libraryprojectimports.cache` to the `@(FileWrites)` group, which prevents MSBuild from (occasionally) deleting the file on [incremental clean][0]. [0]: https://github.com/xamarin/xamarin-android/blob/6cd0d38989178e1c3e5e1d71505b4aef26a1739b/Documentation/guides/MSBuildBestPractices.md#filewrites-and-incrementalclean
On occasion we see the following error when building a Maui app.
Looking in detail at te build log we notice that NONE of the resources in the
$(IntermediateOutputPath)\lpfolderare being included in the call to
aapt2. Looking further we see two very important linesSkipping target "_ResolveLibraryProjectImports" because all output files are up-to-date with respect to the input files.So in this case it seems that the
.cachefile which stores the list of resource directories was created, but was thendeleted later on. A search of our build system shows that this case file was never added to the
FileWritesItemGroup.As a result it gets deleted, but the
.stampfile which controls_ResolveLibraryProjectImportsis left in place. We end up in a situation where the target which generates the cache will NEVER run again because its stamp file is present.Only a full Clean will fix this issue.