Skip to content

Conversation

@jonathanpeppers
Copy link
Member

Fixes: #9974

After updating the DotnetPack test to use:

proj.OtherBuildItems.Add (new AndroidItem.AndroidMavenLibrary ("org.jetbrains.kotlinx:kotlinx-serialization-json-jvm") {
    MetadataValues = "Version=1.3.3;Bind=false",
    BinaryContent = () => [],
});

And then seeing the .jar files inside:

using var aarStream = new MemoryStream ();
var aarEntry = nupkg.ReadEntry (aarPath);
aarEntry.Extract (aarStream);
aarStream.Seek (0, SeekOrigin.Begin);
using var aar = ZipArchive.Open (aarStream);
int count = aar.Count (e =>
    e.FullName.StartsWith ("libs/", StringComparison.OrdinalIgnoreCase) &&
    e.FullName.EndsWith (".jar", StringComparison.OrdinalIgnoreCase));

There were originally 0 files, when there should be 2!

Reviewing the .binlog, dotnet pack has an inner/outer build going on during it:

  • _WalkEachTargetPerFramework target

  • Runs <MSBuild/>, the _GetFrameworkAssemblyReferences target

  • Which calls our _CreateAar target.

If _CreateAar can be called in this scenario, it needs to depend on _CategorizeAndroidLibraries, so none of its inputs are missing.

With this change, the test now asserts that 2 "hashed" .jar files are present in the .nupkg output.

Fixes: #9974

After updating the `DotnetPack` test to use:

    proj.OtherBuildItems.Add (new AndroidItem.AndroidMavenLibrary ("org.jetbrains.kotlinx:kotlinx-serialization-json-jvm") {
        MetadataValues = "Version=1.3.3;Bind=false",
        BinaryContent = () => [],
    });

And then seeing the `.jar` files inside:

    using var aarStream = new MemoryStream ();
    var aarEntry = nupkg.ReadEntry (aarPath);
    aarEntry.Extract (aarStream);
    aarStream.Seek (0, SeekOrigin.Begin);
    using var aar = ZipArchive.Open (aarStream);
    int count = aar.Count (e =>
        e.FullName.StartsWith ("libs/", StringComparison.OrdinalIgnoreCase) &&
        e.FullName.EndsWith (".jar", StringComparison.OrdinalIgnoreCase));

There were originally 0 files, when there *should* be 2!

Reviewing the `.binlog`, `dotnet pack` has an inner/outer build going
on during it:

* `_WalkEachTargetPerFramework` target

* Runs `<MSBuild/>`, the `_GetFrameworkAssemblyReferences` target

* Which calls our `_CreateAar` target.

If `_CreateAar` can be called in this scenario, it needs to depend on
`_CategorizeAndroidLibraries`, so none of its inputs are missing.

With this change, the test now asserts that 2 "hashed `.jar` files are
present in the `.nupkg` output.
@jonathanpeppers jonathanpeppers marked this pull request as ready for review July 9, 2025 18:02
@grendello grendello merged commit 6c2ac38 into main Jul 10, 2025
59 checks passed
@grendello grendello deleted the dev/peppers/fix-dotnet-pack branch July 10, 2025 08:30
@github-actions github-actions bot locked and limited conversation to collaborators Aug 9, 2025
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.

MAUI incorrectly packs JAR dependencies into .nupkg

3 participants