Skip to content

[Mono.Android] Build latest stable version against netcoreapp3.1 #4419

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

Merged
merged 14 commits into from
Mar 24, 2020

Conversation

pjcollins
Copy link
Member

@pjcollins pjcollins commented Mar 18, 2020

Adds netcoreapp3.1 to the set of target frameworks that Mono.Android
will build against in preparation for .NET 5. Additionally, the project build
will effectively be a no-op when targeting netcoreapp3.1 if
$(AndroidFrameworkVersion) is not equal to
$(AndroidLatestStableFrameworkVersion)

@pjcollins pjcollins force-pushed the multitarget-monoandroid branch 4 times, most recently from 5628ee2 to 1368144 Compare March 19, 2020 20:19
@pjcollins pjcollins force-pushed the multitarget-monoandroid branch from 6b1a0ca to 5b6afce Compare March 19, 2020 21:25
@pjcollins
Copy link
Member Author

New build is here, not sure what's up with the duplicate element error above
https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=3569697&view=results

@pjcollins pjcollins marked this pull request as ready for review March 20, 2020 19:11
@pjcollins pjcollins requested a review from jonpryor as a code owner March 20, 2020 19:11
@pjcollins
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@@ -30,6 +30,11 @@
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.1' ">
Copy link
Contributor

Choose a reason for hiding this comment

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

Indentation here is "wonky".

Where should netcoreapp3.1 output go?

Rando thought that I'm trying in PR #4376: place netcoreapp3.1 output into $(topdir)\bin\Debug-netcoreapp3.1.

Better idea -- unimplemented because I don't know the details -- is for files to be included in the .NET 5 support package to follow the appropriate directory structure of the .NET 5 support package. The problem is that I don't know what the directory structure should be...

Copy link
Member Author

@pjcollins pjcollins Mar 23, 2020

Choose a reason for hiding this comment

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

You can find the rough destination package paths here:

I like the idea of better mirroring this output, though there's a couple of questions/concerns. To do this we'll need to only build the latest stable version of Mono.Android.dll when targeting netstandard2.1, and not every supported version. We also ultimately need Mono.Android.dll in both targeting and runtime packs, so we'll need to account for that in the future as well.

I'm not sure how much of this should be considered for this PR. I took a quick look at attempting to only build the latest Mono.Android.dll question and didn't find a great quick solution to that, but we may want to dedicate time to that aspect now at least so that we don't bloat our build times unnecessarily.

Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't netstandard2.1 too restrictive? You won't be able to use any newer APIs.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've updated the second target to netcoreapp3.1.

Copy link
Member Author

@pjcollins pjcollins Mar 23, 2020

Choose a reason for hiding this comment

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

I fixed the indentation, and changed the output path to use the TargetFramework for now, now that only the latest stable version will be built when targeting netcoreapp3.1 I think we can improve this in the future to better mirror the eventual pack layout once we're compiling against netcoreapp5.0 or net5.0.

Copy link
Contributor

Choose a reason for hiding this comment

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

To do this we'll need to only build the latest stable version of Mono.Android.dll when targeting netstandard2.1, and not every supported version.

The intention is that net5-android will redistribute only API-R/API-30 Mono.Android.dll, and not one for every previous $(TargetFrameworkVersion) value.

Copy link
Member Author

Choose a reason for hiding this comment

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

The latest changes ensure that we only build the $(AndroidLatestStableFrameworkVersion ) version of Mono.Android.dll when targeting netcoreapp3.1.

@@ -73,6 +78,11 @@
</Reference>
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.1' ">
<ProjectReference Include="..\..\external\Java.Interop\src\Java.Interop\Java.Interop.csproj" />
<PackageReference Include="System.Drawing.Common" Version="4.7.0" />
Copy link
Member Author

Choose a reason for hiding this comment

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

I believe that this reference was only needed to ensure this attribute compiled successfully:

https://github.com/xamarin/xamarin-android/blob/master/src/Mono.Android/Properties/AssemblyInfo.cs.in#L29

This raises another question though, should we still be including these typeforwards, and the System.Drawing sources when targeting netstandard2.1 (or net5 in the future)?

Copy link
Member Author

Choose a reason for hiding this comment

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

I was able to remove the System.Drawing.Common reference when targeting netcoreapp3.1, however I'm still not sure if we should be including the sources/typeforwards when building against this TargetFramework.

@pjcollins pjcollins added the do-not-merge PR should not be merged. label Mar 23, 2020
@pjcollins pjcollins changed the title [Mono.Android] Also build against netstandard2.1 [Mono.Android] Build latest stable version against netcoreapp3.1 Mar 23, 2020
@pjcollins pjcollins requested a review from grendello as a code owner March 23, 2020 20:20
@@ -13,6 +13,7 @@ abstract class LinuxDebianCommon : Linux
new DebianLinuxProgram ("cli-common-dev"),
new DebianLinuxProgram ("curl"),
new DebianLinuxProgram ("devscripts"),
new DebianLinuxProgram ("dotnet-sdk-3.1"),
Copy link
Contributor

Choose a reason for hiding this comment

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

There's one problem with this dependency - it's not in standard Debian/Ubuntu/etc repositories, so it will fail on an unprepared Debian machine. I think we should at least handle failure to detect or install it with a descriptive error message pointing to the dotnet website with instructions on how to add the repository.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've removed this, it looks like this .NET Core 3.1 installation issue is happening on other PRs as well, we can look to address this issue in a separate PR.

@pjcollins pjcollins force-pushed the multitarget-monoandroid branch 2 times, most recently from 31c3080 to cdd5772 Compare March 23, 2020 21:41
@pjcollins pjcollins force-pushed the multitarget-monoandroid branch from cdd5772 to c6bdcbc Compare March 23, 2020 22:19
@jonpryor
Copy link
Contributor

Commit message:

We expect the .NET 5 BCL to closely resemble the .NET Core 3.1 BCL.
Continue preparing for .NET 5 and build `Mono.Android.dll` against
the `netcoreapp3.1` target framework, to ensure that the APIs that we
need actually exist.

Additionally, the `Mono.Android.csproj` build will effectively be a
no-op when targeting `netcoreapp3.1` if `$(AndroidFrameworkVersion)`
is not equal to `$(AndroidLatestStableFrameworkVersion)`, as we
currently plan on only shipping *one* `Mono.Android.dll` assembly as
part of .NET 5, so there is no need to build `Mono.Android.dll`
against other `$(TargetFrameworkVersion)` values.

When building for `netcoreapp3.1`, `Mono.Android.dll` uses the
`Java.Interop.dll` which is built for .NET Standard, instead of the
one built against the `MonoAndroid` framework.  We may want to
consider updating `Java.Interop.csproj` to multitarget against
`netcoreapp3.1` as well.

@jonpryor jonpryor merged commit e2854ee into master Mar 24, 2020
@jonpryor jonpryor deleted the multitarget-monoandroid branch March 24, 2020 15:56
@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
do-not-merge PR should not be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants