Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into thays_dont_use_debugg…
Browse files Browse the repository at this point in the history
…er_unhandled_exception

* origin/main:
  Bump to dotnet/installer@19943da 6.0.100-rc.1.21372.10 (dotnet#6110)
  [xaprepare] don't install microsoft-net-runtime-android workload (dotnet#6114)
  [Mono.Android] Use `mono_unhandled_exception` for NET6 (dotnet#6104)
  Bump to dotnet/installer@9c463710 6.0.100-rc.1.21369 (dotnet#6072)
  Bump to xamarin/xamarin-android-binutils/2.37-XA.1@77618674 v2.37 (dotnet#6096)
  [Mono.Android.Export] Fix DynamicDependency to JavaArray (dotnet#6105)
  [xaprepare] always delete ~/android-toolchain/dotnet (dotnet#6098)
  [CI] Add nuget to msi conversion and VS insert stage (dotnet#6030)
  [build] delete platform-31 folder on test jobs (dotnet#6103)
  • Loading branch information
thaystg committed Jul 23, 2021
2 parents f16dfc5 + 96eb449 commit 997135f
Show file tree
Hide file tree
Showing 26 changed files with 2,490 additions and 902 deletions.
24 changes: 24 additions & 0 deletions build-tools/automation/azure-pipelines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ stages:

- template: yaml-templates\clean.yaml

- template: yaml-templates\delete-platform-31.yaml

- script: |
echo ##vso[task.setvariable variable=JI_JAVA_HOME]%USERPROFILE%\android-toolchain\$(XA.Jdk11.Folder)
displayName: set JI_JAVA_HOME
Expand Down Expand Up @@ -291,6 +293,8 @@ stages:

- template: yaml-templates\clean.yaml

- template: yaml-templates\delete-platform-31.yaml

- script: |
echo ##vso[task.setvariable variable=JI_JAVA_HOME]%USERPROFILE%\android-toolchain\$(XA.Jdk11.Folder)
displayName: set JI_JAVA_HOME
Expand Down Expand Up @@ -1258,6 +1262,18 @@ stages:
usePipelineArtifactTasks: true
condition: eq(variables['MicroBuildSignType'], 'Real')

# Check - "Xamarin.Android (.NET 6 Preview Installers Convert NuGet to MSI)"
- template: nuget-msi-convert/job/v1.yml@yaml
parameters:
yamlResourceName: yaml
dependsOn: signing
artifactName: nuget-signed
artifactPatterns: |
!*Darwin*
propsArtifactName: nuget-unsigned
signType: $(MicroBuildSignType)
condition: eq(variables['MicroBuildSignType'], 'Real')

# Check - "Xamarin.Android (.NET 6 Preview Installers Create .pkg)"
- job: dotnet_create_pkg
displayName: Create .pkg
Expand Down Expand Up @@ -1454,6 +1470,14 @@ stages:
solution: build-tools\Xamarin.Android.Tools.BootstrapTasks\Xamarin.Android.Tools.BootstrapTasks.csproj
artifactName: Build Results - .NET 6 Preview .msi

# .NET 6 VS Insertion Stage
# Check - "Xamarin.Android (VS Insertion - Wait For Approval)"
# Check - "Xamarin.Android (VS Insertion - Create VS Drop and Open PR)"
- template: vs-insertion/stage/v1.yml@yaml
parameters:
dependsOn: dotnet_installers
condition: eq(variables['MicroBuildSignType'], 'Real')

- stage: finalize_installers
displayName: Finalize Installers
dependsOn: mac_build
Expand Down
10 changes: 10 additions & 0 deletions build-tools/automation/yaml-templates/delete-platform-31.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# NOTE: temporary workaround to delete platform-31
steps:

- script: rm -rfv "$HOME/Library/Android/sdk/platforms/android-31"
displayName: delete API 31
condition: and(succeeded(), eq(variables['agent.os'], 'Darwin'))

- script: if exist "%USERPROFILE%\android-toolchain\sdk\platforms\android-31" rmdir /s /q "%USERPROFILE%\android-toolchain\sdk\platforms\android-31"
displayName: delete API 31
condition: and(succeeded(), eq(variables['agent.os'], 'Windows_NT'))
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ steps:
parameters:
provisionExtraArgs: ${{ parameters.provisionExtraArgs }}

- template: delete-platform-31.yaml

- script: |
echo "##vso[task.setvariable variable=JI_JAVA_HOME]$HOME/Library/Android/${{ parameters.jdkTestFolder }}"
echo "##vso[task.setvariable variable=DOTNET_TOOL_PATH]$HOME/Library/Android/dotnet/dotnet"
Expand Down
8 changes: 7 additions & 1 deletion build-tools/create-packs/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

<UsingTask TaskName="CreateFrameworkListFile" AssemblyFile="$(DotNetSharedFrameworkTaskFile)"/>
<UsingTask TaskName="GenerateBuildManifest" AssemblyFile="$(_MicrosoftDotNetBuildTasksFeedTaskDir)Microsoft.DotNet.Build.Tasks.Feed.dll" />
<UsingTask TaskName="Xamarin.Android.BuildTools.PrepTasks.ReplaceFileContents" AssemblyFile="$(PrepTasksAssembly)" />

<PropertyGroup>
<_MonoAndroidNETOutputDir>$(XAInstallPrefix)xbuild-frameworks\Microsoft.Android\net6.0\</_MonoAndroidNETOutputDir>
Expand Down Expand Up @@ -56,7 +57,7 @@
</Target>

<Target Name="CreateAllPacks"
DependsOnTargets="DeleteExtractedWorkloadPacks;_SetGlobalProperties">
DependsOnTargets="DeleteExtractedWorkloadPacks;_SetGlobalProperties;GetXAVersionInfo">
<RemoveDir Directories="$(XamarinAndroidSourcePath)bin\Build$(Configuration)\nuget-unsigned" />
<Exec Command="dotnet pack @(_GlobalProperties, ' ') -p:AndroidRID=android-arm -p:AndroidABI=armeabi-v7a-net6 &quot;$(MSBuildThisFileDirectory)Microsoft.Android.Runtime.proj&quot;" />
<Exec Command="dotnet pack @(_GlobalProperties, ' ') -p:AndroidRID=android-arm64 -p:AndroidABI=arm64-v8a-net6 &quot;$(MSBuildThisFileDirectory)Microsoft.Android.Runtime.proj&quot;" />
Expand All @@ -69,6 +70,11 @@
<Exec Command="dotnet pack @(_GlobalProperties, ' ') &quot;$(MSBuildThisFileDirectory)Microsoft.Android.Sdk.BundleTool.proj&quot;" />
<Exec Command="dotnet pack @(_GlobalProperties, ' ') &quot;$(MSBuildThisFileDirectory)Microsoft.NET.Sdk.Android.proj&quot;" />
<Exec Command="dotnet pack @(_GlobalProperties, ' ') &quot;$(XamarinAndroidSourcePath)src\Microsoft.Android.Templates\Microsoft.Android.Templates.csproj&quot;" />
<ReplaceFileContents
SourceFile="vs-workload.in.props"
DestinationFile="$(XamarinAndroidSourcePath)bin\Build$(Configuration)\nuget-unsigned\vs-workload.props"
Replacements="@PACK_VERSION_LONG@=$(AndroidPackVersionLong);@PACK_VERSION_SHORT@=$(AndroidMSIVersion);@WORKLOAD_VERSION@=$(AndroidMSIVersion)"
/>
</Target>

<Target Name="ExtractWorkloadPacks"
Expand Down
16 changes: 16 additions & 0 deletions build-tools/create-packs/vs-workload.in.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<PropertyGroup>
<TargetName>Microsoft.NET.Sdk.Android.Workload</TargetName>
</PropertyGroup>
<ItemGroup>
<!-- Shorten package names to avoid long path caching issues in Visual Studio -->
<ShortNames Include="@PACK_VERSION_LONG@">
<Replacement>@PACK_VERSION_SHORT@</Replacement>
</ShortNames>
<ComponentResources Include="android" Category=".NET" Title=".NET SDK for Android" Description=".NET SDK Workload for building Android applications."/>
<ComponentVersions Include="android" Version="@WORKLOAD_VERSION@" />
<ComponentResources Include="android-aot" Category=".NET" Title=".NET SDK for Android with AOT" Description=".NET SDK Workload for building Android applications with AOT support."/>
<ComponentVersions Include="android-aot" Version="@WORKLOAD_VERSION@" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Xamarin.Android.Prepare
//
partial class Configurables
{
const string BinutilsVersion = "2.36.1-XA.1";
const string BinutilsVersion = "2.37-XA.1";

const string MicrosoftOpenJDK11Version = "11.0.10";
const string MicrosoftOpenJDK11Release = "9.1";
Expand Down
67 changes: 2 additions & 65 deletions build-tools/xaprepare/xaprepare/Steps/Step_InstallDotNetPreview.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,65 +21,8 @@ protected override async Task<bool> Execute (Context context)
var dotnetPreviewVersion = context.Properties.GetRequiredValue (KnownProperties.MicrosoftDotnetSdkInternalPackageVersion);
var dotnetTestRuntimeVersion = Configurables.Defaults.DotNetTestRuntimeVersion;

// Delete any custom Microsoft.Android packs that may have been installed by test runs. Other ref/runtime packs will be ignored.
var packsPath = Path.Combine (dotnetPath, "packs");
if (Directory.Exists (packsPath)) {
foreach (var packToRemove in Directory.EnumerateDirectories (packsPath)) {
var info = new DirectoryInfo (packToRemove);
if (info.Name.IndexOf ("Android", StringComparison.OrdinalIgnoreCase) != -1) {
Log.StatusLine ($"Removing Android pack: {packToRemove}");
Utilities.DeleteDirectory (packToRemove);
}
}
}

// Delete Workload manifests, such as sdk-manifests/6.0.100/Microsoft.NET.Sdk.Android
var sdkManifestsPath = Path.Combine (dotnetPath, "sdk-manifests");
if (Directory.Exists (sdkManifestsPath)) {
foreach (var versionBand in Directory.EnumerateDirectories (sdkManifestsPath)) {
foreach (var workloadManifestDirectory in Directory.EnumerateDirectories (versionBand)) {
var info = new DirectoryInfo (workloadManifestDirectory);
if (info.Name.IndexOf ("Android", StringComparison.OrdinalIgnoreCase) != -1) {
Log.StatusLine ($"Removing Android manifest directory: {workloadManifestDirectory}");
Utilities.DeleteDirectory (workloadManifestDirectory);
}
}
}
}

// Delete any unnecessary SDKs if they exist.
var sdkPath = Path.Combine (dotnetPath, "sdk");
if (Directory.Exists (sdkPath)) {
foreach (var sdkToRemove in Directory.EnumerateDirectories (sdkPath).Where (s => new DirectoryInfo (s).Name != dotnetPreviewVersion)) {
Log.StatusLine ($"Removing out of date SDK: {sdkToRemove}");
Utilities.DeleteDirectory (sdkToRemove);
}
}

// Delete Android template-packs
var templatePacksPath = Path.Combine (dotnetPath, "template-packs");
if (Directory.Exists (templatePacksPath)) {
foreach (var templateToRemove in Directory.EnumerateFiles (templatePacksPath)) {
var name = Path.GetFileName (templateToRemove);
if (name.IndexOf ("Android", StringComparison.OrdinalIgnoreCase) != -1) {
Log.StatusLine ($"Removing Android template: {templateToRemove}");
Utilities.DeleteFile (templateToRemove);
}
}
}

// Delete the metadata folder, which contains old workload data
var metadataPath = Path.Combine (dotnetPath, "metadata");
if (Directory.Exists (metadataPath)) {
Utilities.DeleteDirectory (metadataPath);
}

if (File.Exists (dotnetTool)) {
if (!TestDotNetSdk (dotnetTool)) {
Log.WarningLine ($"Attempt to run `dotnet --version` failed, reinstalling the SDK.");
Utilities.DeleteDirectory (dotnetPath);
}
}
// Always delete the ~/android-toolchain/dotnet/ directory
Utilities.DeleteDirectory (dotnetPath);

if (!await InstallDotNetAsync (context, dotnetPath, dotnetPreviewVersion)) {
Log.ErrorLine ($"Installation of dotnet SDK {dotnetPreviewVersion} failed.");
Expand Down Expand Up @@ -108,12 +51,6 @@ protected override async Task<bool> Execute (Context context)
Utilities.CopyFileToDir (file, destination);
}

// Install the microsoft-net-runtime-android workload
if (!Utilities.RunCommand (dotnetTool, BuildPaths.XamarinAndroidSourceRoot, ignoreEmptyArguments: false, new [] { "workload", "install", "microsoft-net-runtime-android", "--skip-manifest-update", "--verbosity", "diag" })) {
Log.ErrorLine ($"dotnet workload install failed.");
return false;
}

return true;
}

Expand Down
12 changes: 6 additions & 6 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<Dependencies>
<ProductDependencies>
<Dependency Name="Microsoft.Dotnet.Sdk.Internal" Version="6.0.100-preview.7.21327.2">
<Dependency Name="Microsoft.Dotnet.Sdk.Internal" Version="6.0.100-rc.1.21372.10">
<Uri>https://github.com/dotnet/installer</Uri>
<Sha>e8b3b6bea1e37086869ba9aeafe65caa298537e7</Sha>
<Sha>19943da31a3470cf59f363f46956edd8a8451af8</Sha>
</Dependency>
<Dependency Name="Microsoft.NET.ILLink.Tasks" Version="6.0.100-preview.6.21322.1" CoherentParentDependency="Microsoft.Dotnet.Sdk.Internal">
<Dependency Name="Microsoft.NET.ILLink.Tasks" Version="6.0.100-preview.6.21370.1" CoherentParentDependency="Microsoft.Dotnet.Sdk.Internal">
<Uri>https://github.com/mono/linker</Uri>
<Sha>a07cab7b71a1321a9e68571c0b6095144a177b4e</Sha>
<Sha>6eae01980dc694107bdee0bc723d75a0dd601f0e</Sha>
</Dependency>
<Dependency Name="Microsoft.NETCore.App.Ref" Version="6.0.0-preview.7.21326.8" CoherentParentDependency="Microsoft.Dotnet.Sdk.Internal">
<Dependency Name="Microsoft.NETCore.App.Ref" Version="6.0.0-rc.1.21372.1" CoherentParentDependency="Microsoft.Dotnet.Sdk.Internal">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>02f70d0b903422282cd7ba8037de6b66ea0b7a2d</Sha>
<Sha>14d6532f388903f425f0a3b9dea697c5a28293d3</Sha>
</Dependency>
</ProductDependencies>
<ToolsetDependencies>
Expand Down
6 changes: 3 additions & 3 deletions eng/Versions.props
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project>
<!--Package versions-->
<PropertyGroup>
<MicrosoftDotnetSdkInternalPackageVersion>6.0.100-preview.7.21327.2</MicrosoftDotnetSdkInternalPackageVersion>
<MicrosoftNETILLinkTasksPackageVersion>6.0.100-preview.6.21322.1</MicrosoftNETILLinkTasksPackageVersion>
<MicrosoftDotnetSdkInternalPackageVersion>6.0.100-rc.1.21372.10</MicrosoftDotnetSdkInternalPackageVersion>
<MicrosoftNETILLinkTasksPackageVersion>6.0.100-preview.6.21370.1</MicrosoftNETILLinkTasksPackageVersion>
<MicrosoftDotNetApiCompatPackageVersion>5.0.0-beta.20181.7</MicrosoftDotNetApiCompatPackageVersion>
<MicrosoftDotNetBuildTasksFeedPackageVersion>6.0.0-beta.21212.6</MicrosoftDotNetBuildTasksFeedPackageVersion>
<MicrosoftNETCoreAppRefPackageVersion>6.0.0-preview.7.21326.8</MicrosoftNETCoreAppRefPackageVersion>
<MicrosoftNETCoreAppRefPackageVersion>6.0.0-rc.1.21372.1</MicrosoftNETCoreAppRefPackageVersion>
</PropertyGroup>
<PropertyGroup>
<!-- Trim all characters after first `-` or `+` is encountered. -->
Expand Down
2 changes: 1 addition & 1 deletion external/Java.Interop
2 changes: 1 addition & 1 deletion src/Mono.Android.Export/CallbackCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ public CodeExpression FromNative (CodeExpression arg)
}

// Ignore ToNative() overload that takes generic instancing mapping. The reflected method should have nothing to do with it.
[DynamicDependency ("ToLocalJniHandle", "Android.Runtime.JavaArray", "Mono.Android")]
[DynamicDependency ("ToLocalJniHandle", "Android.Runtime.JavaArray`1", "Mono.Android")]
[DynamicDependency ("ToLocalJniHandle", "Android.Runtime.JavaCollection", "Mono.Android")]
[DynamicDependency ("ToLocalJniHandle", "Android.Runtime.JavaCollection`1", "Mono.Android")]
[DynamicDependency ("ToLocalJniHandle", "Android.Runtime.JavaDictionary", "Mono.Android")]
Expand Down
15 changes: 14 additions & 1 deletion src/Mono.Android/Android.Runtime/JNIEnv.cs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,9 @@ static void ManualJavaObjectDispose (Java.Lang.Object obj)
internal static Action<Exception> mono_unhandled_exception = null!;
#endif // NETCOREAPP

#if !NETCOREAPP
static Action<AppDomain, UnhandledExceptionEventArgs> AppDomain_DoUnhandledException = null!;
#endif // ndef NETCOREAPP

static void Initialize ()
{
Expand All @@ -258,6 +260,7 @@ static void Initialize ()
mono_unhandled_exception = (Action<Exception>) Delegate.CreateDelegate (typeof(Action<Exception>), mono_UnhandledException);
}

#if !NETCOREAPP
if (AppDomain_DoUnhandledException == null) {
var ad_due = typeof (AppDomain)
.GetMethod ("DoUnhandledException",
Expand All @@ -270,8 +273,14 @@ static void Initialize ()
typeof (Action<AppDomain, UnhandledExceptionEventArgs>), ad_due);
}
}
#endif // ndef NETCOREAPP
}

#if NETCOREAPP
[MethodImplAttribute(MethodImplOptions.InternalCall)]
extern static void monodroid_unhandled_exception (Exception javaException);
#endif // def NETCOREAPP

internal static void PropagateUncaughtException (IntPtr env, IntPtr javaThreadPtr, IntPtr javaExceptionPtr)
{
if (!PropagateExceptions)
Expand All @@ -292,14 +301,18 @@ internal static void PropagateUncaughtException (IntPtr env, IntPtr javaThreadPt
try {
var jltp = javaException as JavaProxyThrowable;
Exception? innerException = jltp?.InnerException;
var args = new UnhandledExceptionEventArgs (innerException ?? javaException, isTerminating: true);

Logger.Log (LogLevel.Info, "MonoDroid", "UNHANDLED EXCEPTION:");
Logger.Log (LogLevel.Info, "MonoDroid", javaException.ToString ());

#if !NETCOREAPP
var args = new UnhandledExceptionEventArgs (innerException ?? javaException, isTerminating: true);
// Disabled until Linker error surfaced in https://github.com/xamarin/xamarin-android/pull/4302#issuecomment-596400025 is resolved
//AppDomain.CurrentDomain.DoUnhandledException (args);
AppDomain_DoUnhandledException?.Invoke (AppDomain.CurrentDomain, args);
#else // ndef NETCOREAPP
monodroid_unhandled_exception (innerException ?? javaException);
#endif // def NETCOREAPP
} catch (Exception e) {
Logger.Log (LogLevel.Error, "monodroid", "Exception thrown while raising AppDomain.UnhandledException event: " + e.ToString ());
}
Expand Down
8 changes: 5 additions & 3 deletions src/Mono.Android/Mono.Android.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<OutputPath>$(XAInstallPrefix)xbuild-frameworks\MonoAndroid\$(AndroidFrameworkVersion)\</OutputPath>
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
<PropertyGroup Condition=" '$(TargetFramework)' != 'monoandroid10' ">
<OutputPath>$(XAInstallPrefix)xbuild-frameworks\Microsoft.Android\$(TargetFramework)\</OutputPath>
</PropertyGroup>

Expand Down Expand Up @@ -348,7 +348,9 @@
<Compile Include="System.Drawing/SizeFConverter.cs" />
<Compile Include="System.IO\AndroidExtensions.cs" />
<Compile Include="System.Linq\Extensions.cs" />
<Compile Include="Xamarin.Android.Net\AndroidClientHandler.cs" />
<Compile Condition=" '$(TargetFramework)' != 'monoandroid10' " Include="Xamarin.Android.Net\AndroidClientHandler.cs" />
<Compile Condition=" '$(TargetFramework)' == 'monoandroid10' " Include="Xamarin.Android.Net\AndroidClientHandler.Legacy.cs" />
<Compile Include="Xamarin.Android.Net\AndroidMessageHandler.cs" />
<Compile Include="Xamarin.Android.Net\AndroidHttpResponseMessage.cs" />
<Compile Include="Xamarin.Android.Net\AuthDigestHeaderParser.cs" />
<Compile Include="Xamarin.Android.Net\AuthDigestSession.cs" />
Expand Down Expand Up @@ -377,7 +379,7 @@

<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
<!-- Only build the 'net6.0' version of 'Mono.Android.dll' once for the latest stable Android version. -->
<PropertyGroup Condition=" '$(TargetFramework)' == 'net6.0' And '$(AndroidFrameworkVersion)' != '$(AndroidLatestStableFrameworkVersion)' ">
<PropertyGroup Condition=" '$(TargetFramework)' != 'monoandroid10' And '$(AndroidFrameworkVersion)' != '$(AndroidLatestStableFrameworkVersion)' ">
<BuildDependsOn></BuildDependsOn>
</PropertyGroup>

Expand Down
Loading

0 comments on commit 997135f

Please sign in to comment.