From 0c9740c3dee8739b4a1ccdd4bc2084683b7a396a Mon Sep 17 00:00:00 2001
From: Peter Collins <peter.collins@xamarin.com>
Date: Wed, 18 Mar 2020 18:42:09 -0400
Subject: [PATCH 01/14] [Mono.Android] Also build against netstandard2.1

Adds `netstandard2.1` to the set of target frameworks that Mono.Android
will build against in preparation for .NET 5.
---
 build-tools/scripts/JavaCallableWrappers.targets |  7 ++++++-
 src/Mono.Android/Android.Runtime/JNIEnv.cs       |  2 ++
 src/Mono.Android/Mono.Android.csproj             | 12 +++++++++++-
 src/Mono.Android/Mono.Android.targets            |  4 +++-
 4 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/build-tools/scripts/JavaCallableWrappers.targets b/build-tools/scripts/JavaCallableWrappers.targets
index 3e8a86ba242..b3257d40384 100644
--- a/build-tools/scripts/JavaCallableWrappers.targets
+++ b/build-tools/scripts/JavaCallableWrappers.targets
@@ -5,11 +5,16 @@
       Inputs="$(JavaCallableWrapperAbsAssembly);@(JavaCallableWrapperSource)"
       Outputs="$(OutputPath)mono.android.jar">
     <MakeDir Directories="$(IntermediateOutputPath)jcw;$(IntermediateOutputPath)jcw\bin" />
+    <ItemGroup>
+      <_NetstandardPath Include="@(ReferencePath->'%(RootDir)%(Directory)')" Condition=" '%(FileName)%(Extension)' == 'netstandard.dll' " />
+    </ItemGroup>
     <PropertyGroup>
       <OutputPathAbs Condition="$([System.IO.Path]::IsPathRooted($(OutputPath)))">$(OutputPath)</OutputPathAbs>
       <OutputPathAbs Condition=" '$(OutputPathAbs)' == '' ">$(MSBuildProjectDirectory)\$(OutputPath)</OutputPathAbs>
       <JcwGen>"$(XAInstallPrefix)xbuild\Xamarin\Android\jcw-gen.exe" -v10</JcwGen>
-      <_LibDirs>-L "$(OutputPathAbs.TrimEnd('\'))" -L "$(OutputPathAbs)..\v1.0" -L "$(OutputPathAbs)..\v1.0\Facades"</_LibDirs>
+      <_LibDirs>-L "$(OutputPathAbs.TrimEnd('\'))"</_LibDirs>
+      <_LibDirs Condition=" '$(TargetFramework)' == 'monoandroid10' ">$(_LibDirs) -L "$(OutputPathAbs)..\v1.0" -L "$(OutputPathAbs)..\v1.0\Facades"</_LibDirs>
+      <_LibDirs Condition=" '$(TargetFramework)' == 'netstandard2.1' ">$(_LibDirs) -L "@(_NetstandardPath)"</_LibDirs>
       <_Out>-o "$(MSBuildProjectDirectory)\$(IntermediateOutputPath)jcw\src"</_Out>
     </PropertyGroup>
     <Exec
diff --git a/src/Mono.Android/Android.Runtime/JNIEnv.cs b/src/Mono.Android/Android.Runtime/JNIEnv.cs
index aa356c88d38..04774035485 100644
--- a/src/Mono.Android/Android.Runtime/JNIEnv.cs
+++ b/src/Mono.Android/Android.Runtime/JNIEnv.cs
@@ -170,7 +170,9 @@ internal static unsafe void Initialize (JnienvInitializeArgs* args)
 			else
 				IdentityHash = v => v;
 
+#if MONOANDROID1_0
 			Mono.SystemDependencyProvider.Initialize ();
+#endif
 
 			BoundExceptionType = (BoundExceptionType)args->ioExceptionType;
 			androidRuntime = new AndroidRuntime (args->env, args->javaVm, androidSdkVersion > 10, args->grefLoader, args->Loader_loadClass, args->jniAddNativeMethodRegistrationAttributePresent != 0);
diff --git a/src/Mono.Android/Mono.Android.csproj b/src/Mono.Android/Mono.Android.csproj
index afcf103b90a..3a75054f243 100644
--- a/src/Mono.Android/Mono.Android.csproj
+++ b/src/Mono.Android/Mono.Android.csproj
@@ -4,7 +4,7 @@
   <Import Project="..\..\Configuration.props" />
 
   <PropertyGroup>
-    <TargetFramework>monoandroid10</TargetFramework>
+    <TargetFrameworks>monoandroid10;netstandard2.1</TargetFrameworks>
     <RootNamespace>Android</RootNamespace>
     <SignAssembly>true</SignAssembly>
     <AssemblyOriginatorKeyFile>..\..\product.snk</AssemblyOriginatorKeyFile>
@@ -30,6 +30,11 @@
     <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
   </PropertyGroup>
 
+   <PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.1' ">
+    <OutputPath>$(XAInstallPrefix)xbuild-frameworks\Xamarin.Android.App\$(AndroidFrameworkVersion)\</OutputPath>
+    <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
+  </PropertyGroup>
+
   <ItemGroup Condition=" '$(TargetFramework)' == 'monoandroid10' ">
     <Reference Include="mscorlib">
       <HintPath>$(OutputPath)..\v1.0\mscorlib.dll</HintPath>
@@ -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" />
+  </ItemGroup>
+
   <ItemGroup>
     <Compile Include="..\..\external\Java.Interop\src\Java.Interop.Tools.TypeNameMappings\Java.Interop.Tools.TypeNameMappings\JavaNativeTypeManager.cs">
       <Link>JavaNativeTypeManager.cs</Link>
diff --git a/src/Mono.Android/Mono.Android.targets b/src/Mono.Android/Mono.Android.targets
index 8602a2bc58b..ebf3780fd6f 100644
--- a/src/Mono.Android/Mono.Android.targets
+++ b/src/Mono.Android/Mono.Android.targets
@@ -10,6 +10,7 @@
   </ItemGroup>
   <Target Name="_BuildJavaInterop"
       BeforeTargets="BeforeResolveReferences"
+      Condition=" '$(TargetFramework)' == 'monoandroid10' "
       Inputs="$(MSBuildThisFile);$(JavaInteropFullPath)\src\Java.Interop\Java.Interop.csproj"
       Outputs="$(OutputPath)\..\v1.0\Java.Interop.dll">
     <PropertyGroup>
@@ -134,6 +135,7 @@
   </ItemGroup>
   <Target Name="_GenerateFrameworkList"
       BeforeTargets="GetTargetFrameworkProperties;GetReferenceAssemblyPaths;ResolveReferences"
+      Condition=" '$(TargetFramework)' == 'monoandroid10' "
       Inputs="$(MSBuildProjectFullPath)"
       Outputs="$(OutputPath)RedistList\FrameworkList.xml">
    <MakeDir Directories="$(OutputPath)RedistList" />
@@ -185,7 +187,7 @@
   <Target
       Name="_CheckApiCompatibility"
       Condition=" '$(DisableApiCompatibilityCheck)' != 'True' "
-      AfterTargets="Build"
+      AfterTargets="CopyFilesToOutputDirectory"
       Inputs="$(TargetPath);@(ApiCompatibilityFiles)"
       Outputs="$(IntermediateOutputPath)CheckApiCompatibility.stamp">
     <CheckApiCompatibility

From bd1670e49490ad8d064fcd4ab6676ac2d0958a18 Mon Sep 17 00:00:00 2001
From: Peter Collins <peter.collins@xamarin.com>
Date: Thu, 19 Mar 2020 10:01:55 -0400
Subject: [PATCH 02/14] Bump to .NET Core 3.1.200

---
 build-tools/automation/azure-pipelines.yaml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/build-tools/automation/azure-pipelines.yaml b/build-tools/automation/azure-pipelines.yaml
index 1624ec527df..38190a53a3b 100644
--- a/build-tools/automation/azure-pipelines.yaml
+++ b/build-tools/automation/azure-pipelines.yaml
@@ -48,7 +48,7 @@ variables:
   InstallerArtifactName: installers
   TestAssembliesArtifactName: test-assemblies
   NUnitConsoleVersion: 3.9.0
-  DotNetCoreVersion: 3.1.100
+  DotNetCoreVersion: 3.1.200
   HostedMacMojave: Hosted Mac Internal Mojave
   HostedMac: Hosted Mac Internal
   HostedWinVS2019: Hosted Windows 2019 with VS2019

From 83d12b15db486c606cabc412d08459fa95cd5131 Mon Sep 17 00:00:00 2001
From: Peter Collins <pecolli@microsoft.com>
Date: Thu, 19 Mar 2020 14:57:06 -0400
Subject: [PATCH 03/14] Trim trailing slash from netstandard path

---
 build-tools/scripts/JavaCallableWrappers.targets | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/build-tools/scripts/JavaCallableWrappers.targets b/build-tools/scripts/JavaCallableWrappers.targets
index b3257d40384..4c4feb9ad9c 100644
--- a/build-tools/scripts/JavaCallableWrappers.targets
+++ b/build-tools/scripts/JavaCallableWrappers.targets
@@ -9,12 +9,13 @@
       <_NetstandardPath Include="@(ReferencePath->'%(RootDir)%(Directory)')" Condition=" '%(FileName)%(Extension)' == 'netstandard.dll' " />
     </ItemGroup>
     <PropertyGroup>
+      <_NetstandardDir>@(_NetstandardPath)</_NetstandardDir>
       <OutputPathAbs Condition="$([System.IO.Path]::IsPathRooted($(OutputPath)))">$(OutputPath)</OutputPathAbs>
       <OutputPathAbs Condition=" '$(OutputPathAbs)' == '' ">$(MSBuildProjectDirectory)\$(OutputPath)</OutputPathAbs>
       <JcwGen>"$(XAInstallPrefix)xbuild\Xamarin\Android\jcw-gen.exe" -v10</JcwGen>
       <_LibDirs>-L "$(OutputPathAbs.TrimEnd('\'))"</_LibDirs>
       <_LibDirs Condition=" '$(TargetFramework)' == 'monoandroid10' ">$(_LibDirs) -L "$(OutputPathAbs)..\v1.0" -L "$(OutputPathAbs)..\v1.0\Facades"</_LibDirs>
-      <_LibDirs Condition=" '$(TargetFramework)' == 'netstandard2.1' ">$(_LibDirs) -L "@(_NetstandardPath)"</_LibDirs>
+      <_LibDirs Condition=" '$(TargetFramework)' == 'netstandard2.1' ">$(_LibDirs) -L "$(_NetstandardDir.TrimEnd('\'))"</_LibDirs>
       <_Out>-o "$(MSBuildProjectDirectory)\$(IntermediateOutputPath)jcw\src"</_Out>
     </PropertyGroup>
     <Exec

From 3b8bb36ab33381aea1d03cd62343eb8db7a90c28 Mon Sep 17 00:00:00 2001
From: Peter Collins <peter.collins@xamarin.com>
Date: Thu, 19 Mar 2020 15:14:52 -0400
Subject: [PATCH 04/14] Pass TargetFramework to JI tool projects

---
 build-tools/automation/azure-pipelines.yaml | 2 +-
 src/Mono.Android/Mono.Android.csproj        | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/build-tools/automation/azure-pipelines.yaml b/build-tools/automation/azure-pipelines.yaml
index 38190a53a3b..1624ec527df 100644
--- a/build-tools/automation/azure-pipelines.yaml
+++ b/build-tools/automation/azure-pipelines.yaml
@@ -48,7 +48,7 @@ variables:
   InstallerArtifactName: installers
   TestAssembliesArtifactName: test-assemblies
   NUnitConsoleVersion: 3.9.0
-  DotNetCoreVersion: 3.1.200
+  DotNetCoreVersion: 3.1.100
   HostedMacMojave: Hosted Mac Internal Mojave
   HostedMac: Hosted Mac Internal
   HostedWinVS2019: Hosted Windows 2019 with VS2019
diff --git a/src/Mono.Android/Mono.Android.csproj b/src/Mono.Android/Mono.Android.csproj
index 3a75054f243..5f20cb73015 100644
--- a/src/Mono.Android/Mono.Android.csproj
+++ b/src/Mono.Android/Mono.Android.csproj
@@ -335,8 +335,9 @@
     <ProjectReference Include="..\..\build-tools\api-merge\api-merge.csproj" ReferenceOutputAssembly="false" />
     <ProjectReference Include="..\..\build-tools\api-xml-adjuster\api-xml-adjuster.csproj" ReferenceOutputAssembly="false" />
     <ProjectReference Include="..\..\build-tools\jnienv-gen\jnienv-gen.csproj" ReferenceOutputAssembly="false" />
-    <ProjectReference Include="..\..\external\Java.Interop\tools\generator\generator.csproj" ReferenceOutputAssembly="false" SkipGetTargetFrameworkProperties="true" />
-    <ProjectReference Include="..\..\external\Java.Interop\tools\jcw-gen\jcw-gen.csproj" ReferenceOutputAssembly="false" SkipGetTargetFrameworkProperties="true" />
+    <!-- Explicitly pass the target framework of the project so we don't have conflicts with the multiple targets in this file. -->
+    <ProjectReference Include="..\..\external\Java.Interop\tools\generator\generator.csproj" ReferenceOutputAssembly="false" SkipGetTargetFrameworkProperties="true" AdditionalProperties="TargetFramework=net472"/>
+    <ProjectReference Include="..\..\external\Java.Interop\tools\jcw-gen\jcw-gen.csproj" ReferenceOutputAssembly="false" SkipGetTargetFrameworkProperties="true" AdditionalProperties="TargetFramework=net472" />
     <ProjectReference Include="..\..\src\java-runtime\java-runtime.csproj" ReferenceOutputAssembly="false" />
   </ItemGroup>
 

From 5b6afce9ed78fb7f17f4d07a471c86773d2404c7 Mon Sep 17 00:00:00 2001
From: Peter Collins <peter.collins@xamarin.com>
Date: Thu, 19 Mar 2020 17:10:04 -0400
Subject: [PATCH 05/14] Fix JCW.targets for OpenTK

---
 build-tools/scripts/JavaCallableWrappers.targets | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/build-tools/scripts/JavaCallableWrappers.targets b/build-tools/scripts/JavaCallableWrappers.targets
index 4c4feb9ad9c..b81c80ffd8a 100644
--- a/build-tools/scripts/JavaCallableWrappers.targets
+++ b/build-tools/scripts/JavaCallableWrappers.targets
@@ -14,7 +14,7 @@
       <OutputPathAbs Condition=" '$(OutputPathAbs)' == '' ">$(MSBuildProjectDirectory)\$(OutputPath)</OutputPathAbs>
       <JcwGen>"$(XAInstallPrefix)xbuild\Xamarin\Android\jcw-gen.exe" -v10</JcwGen>
       <_LibDirs>-L "$(OutputPathAbs.TrimEnd('\'))"</_LibDirs>
-      <_LibDirs Condition=" '$(TargetFramework)' == 'monoandroid10' ">$(_LibDirs) -L "$(OutputPathAbs)..\v1.0" -L "$(OutputPathAbs)..\v1.0\Facades"</_LibDirs>
+      <_LibDirs Condition=" '$(TargetFramework)' != 'netstandard2.1' ">$(_LibDirs) -L "$(OutputPathAbs)..\v1.0" -L "$(OutputPathAbs)..\v1.0\Facades"</_LibDirs>
       <_LibDirs Condition=" '$(TargetFramework)' == 'netstandard2.1' ">$(_LibDirs) -L "$(_NetstandardDir.TrimEnd('\'))"</_LibDirs>
       <_Out>-o "$(MSBuildProjectDirectory)\$(IntermediateOutputPath)jcw\src"</_Out>
     </PropertyGroup>

From 8e4d2f46fbb802f3e839e2d2c0ffdd55f3972ee0 Mon Sep 17 00:00:00 2001
From: Peter Collins <peter.collins@xamarin.com>
Date: Mon, 23 Mar 2020 13:59:57 -0400
Subject: [PATCH 06/14] Bump to netcoreapp3.1, only build latest stable

---
 build-tools/scripts/JavaCallableWrappers.targets |  4 ++--
 src/Mono.Android/Mono.Android.csproj             | 16 +++++++++++-----
 2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/build-tools/scripts/JavaCallableWrappers.targets b/build-tools/scripts/JavaCallableWrappers.targets
index b81c80ffd8a..04fe60cc7fe 100644
--- a/build-tools/scripts/JavaCallableWrappers.targets
+++ b/build-tools/scripts/JavaCallableWrappers.targets
@@ -14,8 +14,8 @@
       <OutputPathAbs Condition=" '$(OutputPathAbs)' == '' ">$(MSBuildProjectDirectory)\$(OutputPath)</OutputPathAbs>
       <JcwGen>"$(XAInstallPrefix)xbuild\Xamarin\Android\jcw-gen.exe" -v10</JcwGen>
       <_LibDirs>-L "$(OutputPathAbs.TrimEnd('\'))"</_LibDirs>
-      <_LibDirs Condition=" '$(TargetFramework)' != 'netstandard2.1' ">$(_LibDirs) -L "$(OutputPathAbs)..\v1.0" -L "$(OutputPathAbs)..\v1.0\Facades"</_LibDirs>
-      <_LibDirs Condition=" '$(TargetFramework)' == 'netstandard2.1' ">$(_LibDirs) -L "$(_NetstandardDir.TrimEnd('\'))"</_LibDirs>
+      <_LibDirs Condition=" '$(TargetFramework)' != 'netcoreapp3.1' ">$(_LibDirs) -L "$(OutputPathAbs)..\v1.0" -L "$(OutputPathAbs)..\v1.0\Facades"</_LibDirs>
+      <_LibDirs Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">$(_LibDirs) -L "$(_NetstandardDir.TrimEnd('\'))"</_LibDirs>
       <_Out>-o "$(MSBuildProjectDirectory)\$(IntermediateOutputPath)jcw\src"</_Out>
     </PropertyGroup>
     <Exec
diff --git a/src/Mono.Android/Mono.Android.csproj b/src/Mono.Android/Mono.Android.csproj
index 5f20cb73015..b0449a65b1b 100644
--- a/src/Mono.Android/Mono.Android.csproj
+++ b/src/Mono.Android/Mono.Android.csproj
@@ -1,10 +1,11 @@
 <?xml version="1.0" encoding="utf-8"?>
-<Project Sdk="Microsoft.NET.Sdk">
+<Project>
 
+  <Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
   <Import Project="..\..\Configuration.props" />
 
   <PropertyGroup>
-    <TargetFrameworks>monoandroid10;netstandard2.1</TargetFrameworks>
+    <TargetFrameworks>monoandroid10;netcoreapp3.1</TargetFrameworks>
     <RootNamespace>Android</RootNamespace>
     <SignAssembly>true</SignAssembly>
     <AssemblyOriginatorKeyFile>..\..\product.snk</AssemblyOriginatorKeyFile>
@@ -30,7 +31,7 @@
     <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
   </PropertyGroup>
 
-   <PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.1' ">
+  <PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">
     <OutputPath>$(XAInstallPrefix)xbuild-frameworks\Xamarin.Android.App\$(AndroidFrameworkVersion)\</OutputPath>
     <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
   </PropertyGroup>
@@ -78,9 +79,8 @@
     </Reference>
   </ItemGroup>
 
-  <ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.1' ">
+  <ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">
     <ProjectReference Include="..\..\external\Java.Interop\src\Java.Interop\Java.Interop.csproj" />
-    <PackageReference Include="System.Drawing.Common" Version="4.7.0" />
   </ItemGroup>
 
   <ItemGroup>
@@ -341,4 +341,10 @@
     <ProjectReference Include="..\..\src\java-runtime\java-runtime.csproj" ReferenceOutputAssembly="false" />
   </ItemGroup>
 
+  <Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
+
+  <PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' And '$(AndroidFrameworkVersion)' != '$(AndroidLatestStableFrameworkVersion)' ">
+    <BuildDependsOn></BuildDependsOn>
+  </PropertyGroup>
+
 </Project>

From ea0370eed95c4b01e3036c7c5a27cbd89f754401 Mon Sep 17 00:00:00 2001
From: Peter Collins <peter.collins@xamarin.com>
Date: Mon, 23 Mar 2020 14:01:22 -0400
Subject: [PATCH 07/14] Add comment

---
 src/Mono.Android/Mono.Android.csproj | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/Mono.Android/Mono.Android.csproj b/src/Mono.Android/Mono.Android.csproj
index b0449a65b1b..e1ab2f9d47b 100644
--- a/src/Mono.Android/Mono.Android.csproj
+++ b/src/Mono.Android/Mono.Android.csproj
@@ -342,7 +342,7 @@
   </ItemGroup>
 
   <Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
-
+  <!-- Only build the 'netcoreapp3.1' version of 'Mono.Android.dll' once for the latest stable Android version. -->
   <PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' And '$(AndroidFrameworkVersion)' != '$(AndroidLatestStableFrameworkVersion)' ">
     <BuildDependsOn></BuildDependsOn>
   </PropertyGroup>

From 43f2bdc5670d13faa3aa563557933516aa8f2bb1 Mon Sep 17 00:00:00 2001
From: Peter Collins <peter.collins@xamarin.com>
Date: Mon, 23 Mar 2020 14:09:39 -0400
Subject: [PATCH 08/14] Use TargetFramework in netcoreapp output path

---
 src/Mono.Android/Mono.Android.csproj | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/Mono.Android/Mono.Android.csproj b/src/Mono.Android/Mono.Android.csproj
index e1ab2f9d47b..774b91ada3f 100644
--- a/src/Mono.Android/Mono.Android.csproj
+++ b/src/Mono.Android/Mono.Android.csproj
@@ -32,8 +32,7 @@
   </PropertyGroup>
 
   <PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">
-    <OutputPath>$(XAInstallPrefix)xbuild-frameworks\Xamarin.Android.App\$(AndroidFrameworkVersion)\</OutputPath>
-    <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
+    <OutputPath>$(XAInstallPrefix)xbuild-frameworks\Xamarin.Android.App\</OutputPath>
   </PropertyGroup>
 
   <ItemGroup Condition=" '$(TargetFramework)' == 'monoandroid10' ">

From 24369090b9fe5d23bef4683dfca75a59c1a10725 Mon Sep 17 00:00:00 2001
From: Peter Collins <peter.collins@xamarin.com>
Date: Mon, 23 Mar 2020 14:34:15 -0400
Subject: [PATCH 09/14] Fix the build

---
 build-tools/scripts/JavaCallableWrappers.targets | 6 +++---
 src/Mono.Android/Mono.Android.csproj             | 3 ++-
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/build-tools/scripts/JavaCallableWrappers.targets b/build-tools/scripts/JavaCallableWrappers.targets
index 04fe60cc7fe..df18fa9cc69 100644
--- a/build-tools/scripts/JavaCallableWrappers.targets
+++ b/build-tools/scripts/JavaCallableWrappers.targets
@@ -6,16 +6,16 @@
       Outputs="$(OutputPath)mono.android.jar">
     <MakeDir Directories="$(IntermediateOutputPath)jcw;$(IntermediateOutputPath)jcw\bin" />
     <ItemGroup>
-      <_NetstandardPath Include="@(ReferencePath->'%(RootDir)%(Directory)')" Condition=" '%(FileName)%(Extension)' == 'netstandard.dll' " />
+      <_CorlibPath Include="@(ReferencePath->'%(RootDir)%(Directory)')" Condition=" '%(FileName)%(Extension)' == 'mscorlib.dll' " />
     </ItemGroup>
     <PropertyGroup>
-      <_NetstandardDir>@(_NetstandardPath)</_NetstandardDir>
+      <_CorlibDir>@(_CorlibPath)</_CorlibDir>
       <OutputPathAbs Condition="$([System.IO.Path]::IsPathRooted($(OutputPath)))">$(OutputPath)</OutputPathAbs>
       <OutputPathAbs Condition=" '$(OutputPathAbs)' == '' ">$(MSBuildProjectDirectory)\$(OutputPath)</OutputPathAbs>
       <JcwGen>"$(XAInstallPrefix)xbuild\Xamarin\Android\jcw-gen.exe" -v10</JcwGen>
       <_LibDirs>-L "$(OutputPathAbs.TrimEnd('\'))"</_LibDirs>
       <_LibDirs Condition=" '$(TargetFramework)' != 'netcoreapp3.1' ">$(_LibDirs) -L "$(OutputPathAbs)..\v1.0" -L "$(OutputPathAbs)..\v1.0\Facades"</_LibDirs>
-      <_LibDirs Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">$(_LibDirs) -L "$(_NetstandardDir.TrimEnd('\'))"</_LibDirs>
+      <_LibDirs Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">$(_LibDirs) -L "$(_CorlibDir.TrimEnd('\'))"</_LibDirs>
       <_Out>-o "$(MSBuildProjectDirectory)\$(IntermediateOutputPath)jcw\src"</_Out>
     </PropertyGroup>
     <Exec
diff --git a/src/Mono.Android/Mono.Android.csproj b/src/Mono.Android/Mono.Android.csproj
index 774b91ada3f..c4bd490a51a 100644
--- a/src/Mono.Android/Mono.Android.csproj
+++ b/src/Mono.Android/Mono.Android.csproj
@@ -32,7 +32,8 @@
   </PropertyGroup>
 
   <PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">
-    <OutputPath>$(XAInstallPrefix)xbuild-frameworks\Xamarin.Android.App\</OutputPath>
+    <OutputPath>$(XAInstallPrefix)xbuild-frameworks\Xamarin.Android.App\$(TargetFramework)\</OutputPath>
+    <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
   </PropertyGroup>
 
   <ItemGroup Condition=" '$(TargetFramework)' == 'monoandroid10' ">

From c6bdcbc23a5cd9eaae22786577b30a6860364884 Mon Sep 17 00:00:00 2001
From: Peter Collins <peter.collins@xamarin.com>
Date: Mon, 23 Mar 2020 16:20:11 -0400
Subject: [PATCH 10/14] Attempt to install .NET Core 3 globally on unix

---
 build-tools/automation/build.groovy       | 4 +++-
 build-tools/automation/build.linux.groovy | 6 +++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/build-tools/automation/build.groovy b/build-tools/automation/build.groovy
index 32a119af200..692871e3dfc 100644
--- a/build-tools/automation/build.groovy
+++ b/build-tools/automation/build.groovy
@@ -174,8 +174,10 @@ timestamps {
                     }
                 }
             }
-            // Install .NET Core and temporarily append it to PATH
+            // Install .NET Core globally
             sh "curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin -version 3.1.100"
+            sh "\$HOME/.dotnet/dotnet tool install --global boots || true"
+            sh "DOTNET_ROOT=\$HOME/.dotnet && \$HOME/.dotnet/tools/boots https://dotnetcli.azureedge.net/dotnet/Sdk/3.1.100/dotnet-sdk-3.1.100-osx-x64.pkg"
         }
 
         utils.stageWithTimeout('build', 6, 'HOURS', XADir, true) {    // Typically takes less than one hour except a build on a new bot to populate local caches can take several hours
diff --git a/build-tools/automation/build.linux.groovy b/build-tools/automation/build.linux.groovy
index ffe138e7690..4f1a9f5469d 100644
--- a/build-tools/automation/build.linux.groovy
+++ b/build-tools/automation/build.linux.groovy
@@ -73,6 +73,8 @@ def execChRootCommand(chRootName, chRootPackages, pBuilderBindMounts, makeComman
         command: """
             export LC_ALL=en_US.UTF-8
             export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
+            export DOTNET_ROOT=\$HOME/dotnet
+            export PATH=\$PATH:\$HOME/dotnet
             locale
 
             ${makeCommand}
@@ -148,7 +150,9 @@ timestamps {
                     buildTarget = 'all'
                 }
             }
-            
+            // Install .NET Core globally
+            sh "curl -o dotnet-sdk-3.1.100-linux-x64.tar.gz https://dotnetcli.azureedge.net/dotnet/Sdk/3.1.100/dotnet-sdk-3.1.100-linux-x64.tar.gz"
+            sh "mkdir -p \$HOME/dotnet && tar zxf dotnet-sdk-3.1.100-linux-x64.tar.gz -C \$HOME/dotnet"
             sh "env"
         }
 

From 62594e102ce8a5e9098a07759b36e056b73c14da Mon Sep 17 00:00:00 2001
From: Peter Collins <peter.collins@xamarin.com>
Date: Tue, 24 Mar 2020 11:18:29 -0400
Subject: [PATCH 11/14] Revert netcore installation changes

---
 build-tools/automation/build.groovy       | 4 +---
 build-tools/automation/build.linux.groovy | 6 +-----
 2 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/build-tools/automation/build.groovy b/build-tools/automation/build.groovy
index 692871e3dfc..32a119af200 100644
--- a/build-tools/automation/build.groovy
+++ b/build-tools/automation/build.groovy
@@ -174,10 +174,8 @@ timestamps {
                     }
                 }
             }
-            // Install .NET Core globally
+            // Install .NET Core and temporarily append it to PATH
             sh "curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin -version 3.1.100"
-            sh "\$HOME/.dotnet/dotnet tool install --global boots || true"
-            sh "DOTNET_ROOT=\$HOME/.dotnet && \$HOME/.dotnet/tools/boots https://dotnetcli.azureedge.net/dotnet/Sdk/3.1.100/dotnet-sdk-3.1.100-osx-x64.pkg"
         }
 
         utils.stageWithTimeout('build', 6, 'HOURS', XADir, true) {    // Typically takes less than one hour except a build on a new bot to populate local caches can take several hours
diff --git a/build-tools/automation/build.linux.groovy b/build-tools/automation/build.linux.groovy
index 4f1a9f5469d..d088586e463 100644
--- a/build-tools/automation/build.linux.groovy
+++ b/build-tools/automation/build.linux.groovy
@@ -73,8 +73,6 @@ def execChRootCommand(chRootName, chRootPackages, pBuilderBindMounts, makeComman
         command: """
             export LC_ALL=en_US.UTF-8
             export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
-            export DOTNET_ROOT=\$HOME/dotnet
-            export PATH=\$PATH:\$HOME/dotnet
             locale
 
             ${makeCommand}
@@ -150,9 +148,7 @@ timestamps {
                     buildTarget = 'all'
                 }
             }
-            // Install .NET Core globally
-            sh "curl -o dotnet-sdk-3.1.100-linux-x64.tar.gz https://dotnetcli.azureedge.net/dotnet/Sdk/3.1.100/dotnet-sdk-3.1.100-linux-x64.tar.gz"
-            sh "mkdir -p \$HOME/dotnet && tar zxf dotnet-sdk-3.1.100-linux-x64.tar.gz -C \$HOME/dotnet"
+
             sh "env"
         }
 

From 247b1ab378c312223cd10d5197a4721c8f57582c Mon Sep 17 00:00:00 2001
From: Peter Collins <peter.collins@xamarin.com>
Date: Tue, 24 Mar 2020 11:19:14 -0400
Subject: [PATCH 12/14] Undo whitespace

---
 build-tools/automation/build.linux.groovy | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/build-tools/automation/build.linux.groovy b/build-tools/automation/build.linux.groovy
index d088586e463..ffe138e7690 100644
--- a/build-tools/automation/build.linux.groovy
+++ b/build-tools/automation/build.linux.groovy
@@ -148,7 +148,7 @@ timestamps {
                     buildTarget = 'all'
                 }
             }
-
+            
             sh "env"
         }
 

From 3e730dde48f8273ab818caea20ce5729a1616c2e Mon Sep 17 00:00:00 2001
From: Peter Collins <peter.collins@xamarin.com>
Date: Tue, 24 Mar 2020 11:32:21 -0400
Subject: [PATCH 13/14] Bump to NuGet v5.5

---
 build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs b/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs
index d37214389e5..5ebee40886b 100644
--- a/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs
+++ b/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs
@@ -30,7 +30,7 @@ public static partial class Urls
 			/// </summary>
 			public static readonly Uri AndroidToolchain_AndroidUri = new Uri ("https://dl.google.com/android/repository/");
 
-			public static readonly Uri NugetUri = new Uri ("https://dist.nuget.org/win-x86-commandline/v4.9.4/nuget.exe");
+			public static readonly Uri NugetUri = new Uri ("https://dist.nuget.org/win-x86-commandline/v5.5.0/nuget.exe");
 
 			public static Uri MonoArchive_BaseUri = new Uri ("https://xamjenkinsartifact.azureedge.net/mono-sdks/");
 		}

From be25f614073efd8d6b3ef9cf7cee93b2678d521d Mon Sep 17 00:00:00 2001
From: Peter Collins <peter.collins@xamarin.com>
Date: Tue, 24 Mar 2020 11:54:33 -0400
Subject: [PATCH 14/14] Revert "Bump to NuGet v5.5"

This reverts commit 3e730dde48f8273ab818caea20ce5729a1616c2e.
---
 build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs b/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs
index 5ebee40886b..d37214389e5 100644
--- a/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs
+++ b/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs
@@ -30,7 +30,7 @@ public static partial class Urls
 			/// </summary>
 			public static readonly Uri AndroidToolchain_AndroidUri = new Uri ("https://dl.google.com/android/repository/");
 
-			public static readonly Uri NugetUri = new Uri ("https://dist.nuget.org/win-x86-commandline/v5.5.0/nuget.exe");
+			public static readonly Uri NugetUri = new Uri ("https://dist.nuget.org/win-x86-commandline/v4.9.4/nuget.exe");
 
 			public static Uri MonoArchive_BaseUri = new Uri ("https://xamjenkinsartifact.azureedge.net/mono-sdks/");
 		}
