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

[One .NET] pack AndroidLibrary .aar files in .nupkg #7045

Merged
merged 2 commits into from
May 31, 2022

Conversation

jonathanpeppers
Copy link
Member

Fixes: #7040

It appears we were missing a test case of:

  1. dotnet new androidlib

  2. Add an .aar file

  3. dotnet pack

  4. Assert that lib\net6.0-android31.0\MyAndroidLibrary.aar exists in
    the .nupkg output

We instead end up with "weird" output in the .nupkg like:

lib\net6.0-android31.0\MyDotNetAssembly.dll
lib\net6.0-android31.0\MyDotNetAssembly.xml
lib\net6.0-android31.0\MyDotNetAssembly.aar
content\MyAndroidLibrary.aar
contentFiles\any\net6.0-android31.0\MyAndroidLibrary.aar

MyDotNetAssembly.aar would contain any .jar files or
AndroidResource files packed inside. However, other .aar files
are supposed to sit next to MyDotNetAssembly.dll.

It was surprisingly difficult to work alongside NuGet's MSBuild
targets to get this to work.

  1. In the _CategorizeAndroidLibraries MSBuild target, mark
    TfmSpecificPackageFile="%(Pack)" to be used in our
    _IncludeAarInNuGetPackage MSBuild target.

  2. Add these files to @(TfmSpecificPackageFileWithRecursiveDir) and
    set %(NuGetRecursiveDir) to empty. Otherwise, these items can
    have %(RecursiveDir) set to some path, and this causes
    sub-directories in the .nupkg output.

I updated several tests for this case. I also updated usage of
XASdkProject.OtherBuildItems to use Sources instead.
OtherBuildItems adds the files to the .csproj, and we should be
testing our wildcards in AutoImport.props. Previously, some of these
items were being added twice in these tests.

Fixes: dotnet#7040

It appears we were missing a test case of:

1. `dotnet new androidlib`

2. Add an `.aar` file

3. `dotnet pack`

4. Assert that `lib\net6.0-android31.0\MyAndroidLibrary.aar` exists in
   the `.nupkg` output

We instead end up with "weird" output in the `.nupkg` like:

    lib\net6.0-android31.0\MyDotNetAssembly.dll
    lib\net6.0-android31.0\MyDotNetAssembly.xml
    lib\net6.0-android31.0\MyDotNetAssembly.aar
    content\MyAndroidLibrary.aar
    contentFiles\any\net6.0-android31.0\MyAndroidLibrary.aar

`MyDotNetAssembly.aar` would contain any `.jar` files or
`AndroidResource` files packed inside. However, *other* `.aar` files
are supposed to sit next to `MyDotNetAssembly.dll`.

It was surprisingly difficult to work alongside NuGet's MSBuild
targets to get this to work.

1. In the `_CategorizeAndroidLibraries` MSBuild target, mark
   `TfmSpecificPackageFile="%(Pack)"` to be used in our
   `_IncludeAarInNuGetPackage` MSBuild target.

2. Add these files to `@(TfmSpecificPackageFileWithRecursiveDir)` and
   set `%(NuGetRecursiveDir)` to empty. Otherwise, these items can
   have `%(RecursiveDir)` set to some path, and this causes
   sub-directories in the `.nupkg` output.

I updated several tests for this case. I also updated usage of
`XASdkProject.OtherBuildItems` to use `Sources` instead.
`OtherBuildItems` adds the files to the `.csproj`, and we should be
testing our wildcards in `AutoImport.props`. Previously, some of these
items were being added twice in these tests.
@jonathanpeppers jonathanpeppers marked this pull request as ready for review May 31, 2022 13:55
@jonathanpeppers jonathanpeppers merged commit 868ef05 into dotnet:main May 31, 2022
@jonathanpeppers jonathanpeppers deleted the nupkg-missing-aars branch May 31, 2022 16:22
@github-actions github-actions bot locked and limited conversation to collaborators Jan 24, 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.

.aar file missing from NuGet package for .net6-android binding
2 participants