Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Xamarin.Android.Build.Tasks] fix duplicate .aar files #8196

Merged
merged 1 commit into from
Jul 19, 2023

Commits on Jul 18, 2023

  1. [Xamarin.Android.Build.Tasks] fix duplicate .aar files

    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.
    jonathanpeppers committed Jul 18, 2023
    Configuration menu
    Copy the full SHA
    359f66d View commit details
    Browse the repository at this point in the history