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

Conversation

jonathanpeppers
Copy link
Member

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.

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 added a commit that referenced this pull request Jul 18, 2023
…roject references (#8193)"

Context: #8196

This reverts commit 02bd7db.

Given the issue found with building .NET MAUI. Let's let the change
"cook" a bit before servicing this change.
@pjcollins
Copy link
Member

The policheck issue looks like it may be caused by a recent update to the tool, and should be fixed by #8197.

Copy link
Contributor

@dellis1972 dellis1972 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks ok.

@jonathanpeppers jonathanpeppers merged commit 3a89e8d into dotnet:main Jul 19, 2023
45 of 48 checks passed
@jonathanpeppers jonathanpeppers deleted the duplicate-aar-files branch July 19, 2023 13:53
grendello added a commit to grendello/xamarin-android that referenced this pull request Jul 20, 2023
* main:
  [Xamarin.Android.Build.Tasks] fix duplicate `.aar` files (dotnet#8196)
grendello added a commit to grendello/xamarin-android that referenced this pull request Jul 24, 2023
* main:
  $(AndroidPackVersionSuffix)=rc.1; net8 is 34.0.0-rc.1 (dotnet#8204)
  Bump to dotnet/installer@ca467d68c8 8.0.100-preview.7.23364.32 (dotnet#8176)
  Clean up DotNetIgnore Unit Tests (dotnet#8163)
  [Xamarin.Android.Build.Tasks] fix duplicate `.aar` files (dotnet#8196)
  [Documentation] Appease PoliCheck Rule: 79604 (dotnet#8197)
@github-actions github-actions bot locked and limited conversation to collaborators Jan 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants