Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Xamarin.Android.Build.Tasks] fix duplicate
.aar
files (#8196)
Context: dotnet/maui#16024 (comment) .NET MAUI's build currently fails with: Xamarin.Android.Aapt2.targets(123,3): error APT2144: invalid file path 'D:\a\_work\1\s\src\Core\src\obj\Debug\net8.0-android\lp\129.stamp'. What is very wrong about this, it is trying to `aapt2 compile` a `*.stamp` file: Executing compile -o /Users/builder/azdo/_work/1/s/src/Core/src/obj/Release/net8.0-android/lp/87/jl/res/../flat/ /Users/builder/azdo/_work/1/s/src/Core/src/obj/Release/net8.0-android/lp/87.stamp Normally this runs against `*.flat` or `*.flata` files. This problem was introduced in 26ffd5d: 1. Library A uses an AndroidX package, the AndroidX `.aar` file is added to `@(AndroidAarLibrary)`. The NuGet package does this in a `.targets` file. 2. With the change in 26ffd5d, the `.aar` is copied to Library A's build output. 3. Library B uses the same AndroidX package and references Library A. 4. Library B now has duplicate `.aar` files & has the weird build error! I could reproduce the issue in a test. There *may* be a second bug here, but we should update our logic to be: <!-- .aar files should be copied to $(OutputPath) in .NET 6--> <None Include="@(AndroidLibrary)" Condition=" '%(AndroidLibrary.Extension)' == '.aar' " ... /> <!-- @(LibraryProjectZip) items that are not in @(AndroidLibrary) --> <None Include="@(LibraryProjectZip)" Exclude="@(AndroidLibrary)" ... /> So we now only copy: * The new `@(AndroidLibrary)` item group with an `.aar` extension. *Not* `@(AndroidAarLibrary)`. * Any `@(LibraryProjectZip)` that are *not* in `@(AndroidLibrary)`. This supports the classic item group name, keeping our behavior before. Now the new test and the test updated in 26ffd5d both pass.
- Loading branch information