Skip to content

Conversation

@jonathanpeppers
Copy link
Member

@jonathanpeppers jonathanpeppers commented Sep 15, 2020

The Microsoft.Android.Ref.nupkg file is meant to only contain
reference assemblies, and we are currently shipping the real assembly.

The actual runtime assembly is found in the runtime pack for each RID:

  • Microsoft.Android.Runtime.android.21-arm.nupkg
  • Microsoft.Android.Runtime.android.21-arm64.nupkg
  • Microsoft.Android.Runtime.android.21-x86.nupkg
  • Microsoft.Android.Runtime.android.21-x64.nupkg

To fix this, we need to set $(ProduceReferenceAssembly) for each
assembly we distribute in Microsoft.Android.Ref.

The MSBuild targets in dotnet/sdk already handle passing the correct
reference assembly to the <Csc/> MSBuild task, and passing us the
runtime assembly to place in .apk files.

I also cleaned up Mono.Android.Export.csproj so we don't need to
clear $(BuildDependsOn) after manually importing Micrsoft.NET.Sdk.
We could simply change $(TargetFrameworks) instead.

Using a reference assembly has the benefit of saving ~3.5 MB of file
size:

Length Name
------ ----
7167945 Microsoft.Android.Ref.11.0.100-ci.master.120.nupkg
3641811 Microsoft.Android.Ref.11.0.100-ci.microsoft-android-ref.121.nupkg

And saves ~18.9 MB when extracted:

        Size   Compressed  Name
------------ ------------  ------------------------
    32411136      6748183  ref\net5.0\Mono.Android.dll
       78336        30619  ref\net5.0\Mono.Android.Export.dll
    13564928      3244535  ref\net5.0\Mono.Android.dll
       22016         8077  ref\net5.0\Mono.Android.Export.dll

We will need a future change in xamarin/java.interop to make a
reference assembly for Java.Interop.dll.

The `Microsoft.Android.Ref.nupkg` file is meant to only contain
reference assemblies, and we are currently shipping the *real* assembly.

The actual runtime assembly is found in the runtime pack for each RID:

* `Microsoft.Android.Runtime.android.21-arm.nupkg`
* `Microsoft.Android.Runtime.android.21-arm64.nupkg`
* `Microsoft.Android.Runtime.android.21-x86.nupkg`
* `Microsoft.Android.Runtime.android.21-x64.nupkg`

To fix this, we need to set `$(ProduceReferenceAssembly)` for each
assembly we distribute in `Microsoft.Android.Ref`.

The MSBuild targets in dotnet/sdk already handle passing the correct
reference assembly to the `<Csc/>` MSBuild task, and passing us the
runtime assembly to place in `.apk` files.

I also cleaned up `Mono.Android.Export.csproj` so we don't need to
clear `$(BuildDependsOn)` after manually importing `Micrsoft.NET.Sdk`.
We could simply change `$(TargetFrameworks)` instead.

Using a reference assembly has the benefit of saving ~3.5 MB of file
size:

    Length Name
    ------ ----
    7167945 Microsoft.Android.Ref.11.0.100-ci.master.120.nupkg
    3641811 Microsoft.Android.Ref.11.0.100-ci.microsoft-android-ref.121.nupkg

And saves ~18.9 MB when extracted:

            Size   Compressed  Name
    ------------ ------------  ------------------------
        32411136      6748183  ref\net5.0\Mono.Android.dll
           78336        30619  ref\net5.0\Mono.Android.Export.dll
        13564928      3244535  ref\net5.0\Mono.Android.dll
           22016         8077  ref\net5.0\Mono.Android.Export.dll

We will need a future change in xamarin/java.interop to make a
reference assembly for `Java.Interop.dll`.
@jonathanpeppers jonathanpeppers marked this pull request as ready for review September 16, 2020 01:05
jonathanpeppers added a commit to jonathanpeppers/java.interop that referenced this pull request Sep 16, 2020
Context: dotnet/android#5119

The `Microsoft.Android.Ref` package for .NET 6 needs to contain
reference assemblies for each assembly we ship.

`Java.Interop.dll` is one of these, so we need to set
`$(ProduceReferenceAssembly)` to generate a reference assembly
automatically.

Size difference:

    Length Name
    ------ ----
    227328 Java.Interop.dll
     94208 ref/Java.Interop.dll
@jonpryor jonpryor merged commit 00c2c1a into dotnet:master Sep 16, 2020
@jonathanpeppers jonathanpeppers deleted the microsoft.android.ref branch September 16, 2020 17:40
@github-actions github-actions bot locked and limited conversation to collaborators Jan 27, 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.

5 participants