From 1e808971b0789ee51db9df249bf338fe7d779135 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Fri, 30 Apr 2021 08:04:03 -0500 Subject: [PATCH 1/3] [build] target net6.0 instead of netcoreapp3.1 Context: https://github.com/xamarin/xamarin-android/pull/5891 Context: https://github.com/xamarin/xamarin-android/commit/e59f6493fedd789cbd3157d369104516cfffd3f0 xamarin-android should imminently be building libraries targeting `net6.0` instead of `netcoreapp3.1`. We should be able to do this now, because Mono 6.12.0.137 supports building both .NET 5.0 and .NET 6.0. --- Directory.Build.props | 5 ++-- .../Java.Interop.BootstrapTasks/JdkInfo.cs | 5 ++++ build-tools/automation/azure-pipelines.yaml | 23 +++++++++++-------- .../templates/install-dependencies.yaml | 1 + build-tools/jnienv-gen/jnienv-gen.csproj | 2 +- build-tools/scripts/Prepare.targets | 1 + build-tools/scripts/jdk.mk | 1 + build-tools/scripts/jdk.targets | 1 + global.json | 3 +++ .../Java.Interop.Export.csproj | 2 +- .../Java.Interop.GenericMarshaler.csproj | 2 ++ src/Java.Interop/Java.Interop.csproj | 15 +++++++++++- src/java-interop/java-interop.csproj | 2 +- .../Java.Interop-PerformanceTests.csproj | 2 +- .../Java.Interop-Tests.csproj | 6 ++--- tests/TestJVM/TestJVM.csproj | 2 +- .../Directory.Build.targets | 2 +- .../invocation-overhead.csproj | 2 +- tools/class-parse/class-parse.csproj | 2 +- tools/generator/generator.csproj | 2 +- tools/jcw-gen/jcw-gen.csproj | 2 +- tools/logcat-parse/logcat-parse.csproj | 2 +- .../param-name-importer.csproj | 4 ++-- 23 files changed, 60 insertions(+), 29 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index bb59986b2..31e0082f2 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -27,7 +27,7 @@ False obj\ - + True @@ -50,6 +50,7 @@ $(MSBuildThisFileDirectory)external\xamarin-android-tools + dotnet cmake $(MSBuildThisFileDirectory)build-tools\gradle $(GradleHome)\gradlew @@ -67,7 +68,7 @@ mono <_JNIEnvGenPath Condition=" '$(JIBuildingForNetCoreApp)' == 'True' ">$(BuildToolOutputFullPath)jnienv-gen.dll <_JNIEnvGenPath Condition=" '$(JIBuildingForNetCoreApp)' != 'True' ">$(BuildToolOutputFullPath)jnienv-gen.exe - <_RunJNIEnvGen Condition=" '$(JIBuildingForNetCoreApp)' == 'True' ">dotnet "$(_JNIEnvGenPath)" + <_RunJNIEnvGen Condition=" '$(JIBuildingForNetCoreApp)' == 'True' ">$(DotNetToolPath) "$(_JNIEnvGenPath)" <_RunJNIEnvGen Condition=" '$(JIBuildingForNetCoreApp)' != 'True' ">$(Runtime) "$(_JNIEnvGenPath)" diff --git a/build-tools/Java.Interop.BootstrapTasks/Java.Interop.BootstrapTasks/JdkInfo.cs b/build-tools/Java.Interop.BootstrapTasks/Java.Interop.BootstrapTasks/JdkInfo.cs index 31acad96a..b16ffb3f8 100644 --- a/build-tools/Java.Interop.BootstrapTasks/Java.Interop.BootstrapTasks/JdkInfo.cs +++ b/build-tools/Java.Interop.BootstrapTasks/Java.Interop.BootstrapTasks/JdkInfo.cs @@ -21,6 +21,8 @@ public class JdkInfo : Task public string MaximumJdkVersion { get; set; } + public string DotNetToolPath { get; set; } + static Regex VersionExtractor = new Regex (@"(?[\d]+(\.\d+)+)", RegexOptions.Compiled); [Required] @@ -95,6 +97,7 @@ Action CreateLogger () void WritePropertyFile (string javaPath, string jarPath, string javacPath, string jdkJvmPath, string rtJarPath, IEnumerable includes) { + var dotnet = string.IsNullOrEmpty (DotNetToolPath) ? "dotnet" : DotNetToolPath; var msbuild = XNamespace.Get ("http://schemas.microsoft.com/developer/msbuild/2003"); var project = new XElement (msbuild + "Project", new XElement (msbuild + "Choose", @@ -112,6 +115,8 @@ void WritePropertyFile (string javaPath, string jarPath, string javacPath, strin javacPath), new XElement (msbuild + "JarPath", new XAttribute ("Condition", " '$(JarPath)' == '' "), jarPath), + new XElement (msbuild + "DotNetToolPath", new XAttribute ("Condition", " '$(DotNetToolPath)' == '' "), + dotnet), CreateJreRtJarPath (msbuild, rtJarPath))); project.Save (PropertyFile.ItemSpec); } diff --git a/build-tools/automation/azure-pipelines.yaml b/build-tools/automation/azure-pipelines.yaml index 25b80de03..c163b2203 100644 --- a/build-tools/automation/azure-pipelines.yaml +++ b/build-tools/automation/azure-pipelines.yaml @@ -19,10 +19,10 @@ variables: RunningOnCI: true Build.Configuration: Release MaxJdkVersion: 8 - DotNetCoreVersion: 5.0.103 + DotNetCoreVersion: 6.0.x HostedMacImage: macOS-10.15 HostedWinVS2019: Hosted Windows 2019 with VS2019 - NetCoreTargetFrameworkPathSuffix: -netcoreapp3.1 + NetCoreTargetFrameworkPathSuffix: -net6.0 VSInstallRoot: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise jobs: @@ -38,15 +38,13 @@ jobs: - template: templates\install-dependencies.yaml - - task: NuGetToolInstaller@0 + - task: MSBuild@1 + displayName: MSBuild Java.Interop.sln /t:Restore inputs: - versionSpec: 5.x + solution: Java.Interop.sln + configuration: $(Build.Configuration) + msbuildArguments: /t:Restore /p:RestoreConfigFile=$(System.DefaultWorkingDirectory)\external\xamarin-android-tools\NuGet.config - - task: NuGetCommand@2 - inputs: - command: custom - arguments: restore external\xamarin-android-tools\Xamarin.Android.Tools.sln -ConfigFile external\xamarin-android-tools\NuGet.config - - task: MSBuild@1 displayName: MSBuild Java.Interop.sln /t:Prepare inputs: @@ -108,7 +106,12 @@ jobs: submodules: recursive - template: templates\install-dependencies.yaml - + + - script: > + dotnet tool install --global boots && + boots --preview Mono + displayName: Install Mono + - script: make prepare CONFIGURATION=$(Build.Configuration) JI_MAX_JDK=$(MaxJdkVersion) displayName: make prepare diff --git a/build-tools/automation/templates/install-dependencies.yaml b/build-tools/automation/templates/install-dependencies.yaml index 496379a56..a8a0040f5 100644 --- a/build-tools/automation/templates/install-dependencies.yaml +++ b/build-tools/automation/templates/install-dependencies.yaml @@ -6,3 +6,4 @@ steps: displayName: Use .NET Core $(DotNetCoreVersion) inputs: version: $(DotNetCoreVersion) + includePreviewVersions: true diff --git a/build-tools/jnienv-gen/jnienv-gen.csproj b/build-tools/jnienv-gen/jnienv-gen.csproj index 11caad93f..71466f043 100644 --- a/build-tools/jnienv-gen/jnienv-gen.csproj +++ b/build-tools/jnienv-gen/jnienv-gen.csproj @@ -2,7 +2,7 @@ Exe - net472;netcoreapp3.1 + net472;net6.0 false $(BaseIntermediateOutputPath)$(Configuration)\$(TargetFramework.ToLowerInvariant())\ diff --git a/build-tools/scripts/Prepare.targets b/build-tools/scripts/Prepare.targets index 71f7e70d3..29b4fe4cf 100644 --- a/build-tools/scripts/Prepare.targets +++ b/build-tools/scripts/Prepare.targets @@ -15,6 +15,7 @@ JdksRoot="$(ProgramFiles)\Java" MakeFragmentFile="$(MSBuildThisFileDirectory)..\..\bin\Build$(Configuration)\JdkInfo.mk" MaximumJdkVersion="$(_MaxJdk)" + DotNetToolPath="$(DotNetToolPath)" PropertyFile="$(_TopDir)\bin\Build$(Configuration)\JdkInfo.props"> diff --git a/build-tools/scripts/jdk.mk b/build-tools/scripts/jdk.mk index f078f78a6..18b1fe660 100644 --- a/build-tools/scripts/jdk.mk +++ b/build-tools/scripts/jdk.mk @@ -45,4 +45,5 @@ endif # $(OS)=Linux $(_INCLUDE_MK) $(_INCLUDE_PROPS): bin/Build$(CONFIGURATION)/Java.Interop.BootstrapTasks.dll $(MSBUILD) $(MSBUILD_FLAGS) build-tools/scripts/jdk.targets /t:GetPreferredJdkRoot \ /p:JdksRoot="$(_JDKS_ROOT)" \ + /p:DotNetToolPath="$(DOTNET_TOOL_PATH)" \ $(if $(JI_MAX_JDK),"/p:MaximumJdkVersion=$(JI_MAX_JDK)") diff --git a/build-tools/scripts/jdk.targets b/build-tools/scripts/jdk.targets index df083e8aa..f43df8e8a 100644 --- a/build-tools/scripts/jdk.targets +++ b/build-tools/scripts/jdk.targets @@ -6,6 +6,7 @@ JdksRoot="$(JdksRoot)" MakeFragmentFile="$(MSBuildThisFileDirectory)..\..\bin\Build$(Configuration)\JdkInfo.mk" MaximumJdkVersion="$(MaximumJdkVersion)" + DotNetToolPath="$(DotNetToolPath)" PropertyFile="$(MSBuildThisFileDirectory)..\..\bin\Build$(Configuration)\JdkInfo.props"> diff --git a/global.json b/global.json index 8831967d8..40c464e57 100644 --- a/global.json +++ b/global.json @@ -1,4 +1,7 @@ { + "sdk": { + "allowPrerelease": true + }, "msbuild-sdks": { "Microsoft.Build.NoTargets": "2.0.1" } diff --git a/src/Java.Interop.Export/Java.Interop.Export.csproj b/src/Java.Interop.Export/Java.Interop.Export.csproj index d608d87ee..8d923e92d 100644 --- a/src/Java.Interop.Export/Java.Interop.Export.csproj +++ b/src/Java.Interop.Export/Java.Interop.Export.csproj @@ -1,7 +1,7 @@ - netstandard2.0;netcoreapp3.1 + netstandard2.0;net6.0 8.0 {B501D075-6183-4E1D-92C9-F7B5002475B1} true diff --git a/src/Java.Interop.GenericMarshaler/Java.Interop.GenericMarshaler.csproj b/src/Java.Interop.GenericMarshaler/Java.Interop.GenericMarshaler.csproj index 099b50ec5..62da24d00 100644 --- a/src/Java.Interop.GenericMarshaler/Java.Interop.GenericMarshaler.csproj +++ b/src/Java.Interop.GenericMarshaler/Java.Interop.GenericMarshaler.csproj @@ -24,6 +24,8 @@ {94BD81F7-B06F-4295-9636-F8A3B6BDC762} Java.Interop + true + TargetFramework=netstandard2.0 \ No newline at end of file diff --git a/src/Java.Interop/Java.Interop.csproj b/src/Java.Interop/Java.Interop.csproj index 88eadd83d..263a61de3 100644 --- a/src/Java.Interop/Java.Interop.csproj +++ b/src/Java.Interop/Java.Interop.csproj @@ -4,8 +4,19 @@ ..\..\bin\Build$(Configuration)\XAConfig.props + + + netstandard2.0 + <_JniEnvSkipGetTargetFrameworkProperties>true + <_JniEnvAdditionalProperties>TargetFramework=net472 + + + netstandard2.0;net6.0 + - netstandard2.0;netcoreapp3.1 1591 true ..\..\product.snk @@ -57,6 +68,8 @@ diff --git a/src/java-interop/java-interop.csproj b/src/java-interop/java-interop.csproj index 4db957592..20b5ef3c3 100644 --- a/src/java-interop/java-interop.csproj +++ b/src/java-interop/java-interop.csproj @@ -1,6 +1,6 @@ - net472;netcoreapp3.1 + net472;net6.0 $(ToolOutputFullPath) $(BuildToolOutputFullPath) java-interop diff --git a/tests/Java.Interop-PerformanceTests/Java.Interop-PerformanceTests.csproj b/tests/Java.Interop-PerformanceTests/Java.Interop-PerformanceTests.csproj index 33cee5a8e..ae3295562 100644 --- a/tests/Java.Interop-PerformanceTests/Java.Interop-PerformanceTests.csproj +++ b/tests/Java.Interop-PerformanceTests/Java.Interop-PerformanceTests.csproj @@ -1,7 +1,7 @@  - net472;netcoreapp3.1 + net472;net6.0 false true diff --git a/tests/Java.Interop-Tests/Java.Interop-Tests.csproj b/tests/Java.Interop-Tests/Java.Interop-Tests.csproj index a39a8e8f1..a04402fd4 100644 --- a/tests/Java.Interop-Tests/Java.Interop-Tests.csproj +++ b/tests/Java.Interop-Tests/Java.Interop-Tests.csproj @@ -1,7 +1,7 @@ - net472;netcoreapp3.1 + net472;net6.0 false true @@ -10,7 +10,7 @@ $(TestOutputFullPath) - + $(DefineConstants);NO_MARSHAL_MEMBER_BUILDER_SUPPORT;NO_GC_BRIDGE_SUPPORT @@ -37,7 +37,7 @@ - + diff --git a/tests/TestJVM/TestJVM.csproj b/tests/TestJVM/TestJVM.csproj index ab52b760f..809df0552 100644 --- a/tests/TestJVM/TestJVM.csproj +++ b/tests/TestJVM/TestJVM.csproj @@ -1,7 +1,7 @@ - net472;netcoreapp3.1 + net472;net6.0 false diff --git a/tests/invocation-overhead/Directory.Build.targets b/tests/invocation-overhead/Directory.Build.targets index 923147232..40974f9e9 100644 --- a/tests/invocation-overhead/Directory.Build.targets +++ b/tests/invocation-overhead/Directory.Build.targets @@ -29,7 +29,7 @@ Targets="_Run_net472" /> diff --git a/tests/invocation-overhead/invocation-overhead.csproj b/tests/invocation-overhead/invocation-overhead.csproj index 36117f0a1..15ab142b9 100644 --- a/tests/invocation-overhead/invocation-overhead.csproj +++ b/tests/invocation-overhead/invocation-overhead.csproj @@ -2,7 +2,7 @@ Exe - net472;netcoreapp3.1 + net472;net6.0 True True FEATURE_JNIENVIRONMENT_JI_INTPTRS;FEATURE_JNIENVIRONMENT_JI_PINVOKES;FEATURE_JNIENVIRONMENT_SAFEHANDLES;FEATURE_JNIENVIRONMENT_XA_INTPTRS diff --git a/tools/class-parse/class-parse.csproj b/tools/class-parse/class-parse.csproj index 43f43f3de..4dc32967b 100644 --- a/tools/class-parse/class-parse.csproj +++ b/tools/class-parse/class-parse.csproj @@ -1,7 +1,7 @@  - net472;netcoreapp3.1 + net472;net6.0 Exe diff --git a/tools/generator/generator.csproj b/tools/generator/generator.csproj index 80bcf2b0f..34e613108 100644 --- a/tools/generator/generator.csproj +++ b/tools/generator/generator.csproj @@ -1,7 +1,7 @@  - net472;netcoreapp3.1 + net472;net6.0 Exe $(DefineConstants);GENERATOR;HAVE_CECIL;JCW_ONLY_TYPE_NAMES 8.0 diff --git a/tools/jcw-gen/jcw-gen.csproj b/tools/jcw-gen/jcw-gen.csproj index 16ae9a47e..5fddaafc9 100644 --- a/tools/jcw-gen/jcw-gen.csproj +++ b/tools/jcw-gen/jcw-gen.csproj @@ -1,7 +1,7 @@  - net472;netcoreapp3.1 + net472;net6.0 Exe diff --git a/tools/logcat-parse/logcat-parse.csproj b/tools/logcat-parse/logcat-parse.csproj index e189818e2..a5d083424 100644 --- a/tools/logcat-parse/logcat-parse.csproj +++ b/tools/logcat-parse/logcat-parse.csproj @@ -1,7 +1,7 @@  - net472;netcoreapp3.1 + net472;net6.0 Exe diff --git a/tools/param-name-importer/param-name-importer.csproj b/tools/param-name-importer/param-name-importer.csproj index e2105d242..2b020a3f7 100644 --- a/tools/param-name-importer/param-name-importer.csproj +++ b/tools/param-name-importer/param-name-importer.csproj @@ -1,6 +1,6 @@ - net472;netcoreapp3.1 + net472;net6.0 Exe @@ -12,7 +12,7 @@ - From 31efa42d25569accf5db50695e155fb757cad23d Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Tue, 4 May 2021 08:20:33 -0500 Subject: [PATCH 2/3] Put comment back the way it was --- tools/param-name-importer/param-name-importer.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/param-name-importer/param-name-importer.csproj b/tools/param-name-importer/param-name-importer.csproj index 2b020a3f7..6aa6f057c 100644 --- a/tools/param-name-importer/param-name-importer.csproj +++ b/tools/param-name-importer/param-name-importer.csproj @@ -12,7 +12,7 @@ - From 90fec6b7b2b0486258d25cf37a9ac86df96d255b Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Tue, 4 May 2021 14:24:04 -0500 Subject: [PATCH 3/3] DotNetToolPath -> DotnetToolPath --- Directory.Build.props | 4 ++-- .../Java.Interop.BootstrapTasks/JdkInfo.cs | 6 +++--- build-tools/scripts/Prepare.targets | 2 +- build-tools/scripts/jdk.mk | 2 +- build-tools/scripts/jdk.targets | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 31e0082f2..0fca5ff0e 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -50,7 +50,7 @@ $(MSBuildThisFileDirectory)external\xamarin-android-tools - dotnet + dotnet cmake $(MSBuildThisFileDirectory)build-tools\gradle $(GradleHome)\gradlew @@ -68,7 +68,7 @@ mono <_JNIEnvGenPath Condition=" '$(JIBuildingForNetCoreApp)' == 'True' ">$(BuildToolOutputFullPath)jnienv-gen.dll <_JNIEnvGenPath Condition=" '$(JIBuildingForNetCoreApp)' != 'True' ">$(BuildToolOutputFullPath)jnienv-gen.exe - <_RunJNIEnvGen Condition=" '$(JIBuildingForNetCoreApp)' == 'True' ">$(DotNetToolPath) "$(_JNIEnvGenPath)" + <_RunJNIEnvGen Condition=" '$(JIBuildingForNetCoreApp)' == 'True' ">$(DotnetToolPath) "$(_JNIEnvGenPath)" <_RunJNIEnvGen Condition=" '$(JIBuildingForNetCoreApp)' != 'True' ">$(Runtime) "$(_JNIEnvGenPath)" diff --git a/build-tools/Java.Interop.BootstrapTasks/Java.Interop.BootstrapTasks/JdkInfo.cs b/build-tools/Java.Interop.BootstrapTasks/Java.Interop.BootstrapTasks/JdkInfo.cs index b16ffb3f8..53981a60e 100644 --- a/build-tools/Java.Interop.BootstrapTasks/Java.Interop.BootstrapTasks/JdkInfo.cs +++ b/build-tools/Java.Interop.BootstrapTasks/Java.Interop.BootstrapTasks/JdkInfo.cs @@ -21,7 +21,7 @@ public class JdkInfo : Task public string MaximumJdkVersion { get; set; } - public string DotNetToolPath { get; set; } + public string DotnetToolPath { get; set; } static Regex VersionExtractor = new Regex (@"(?[\d]+(\.\d+)+)", RegexOptions.Compiled); @@ -97,7 +97,7 @@ Action CreateLogger () void WritePropertyFile (string javaPath, string jarPath, string javacPath, string jdkJvmPath, string rtJarPath, IEnumerable includes) { - var dotnet = string.IsNullOrEmpty (DotNetToolPath) ? "dotnet" : DotNetToolPath; + var dotnet = string.IsNullOrEmpty (DotnetToolPath) ? "dotnet" : DotnetToolPath; var msbuild = XNamespace.Get ("http://schemas.microsoft.com/developer/msbuild/2003"); var project = new XElement (msbuild + "Project", new XElement (msbuild + "Choose", @@ -115,7 +115,7 @@ void WritePropertyFile (string javaPath, string jarPath, string javacPath, strin javacPath), new XElement (msbuild + "JarPath", new XAttribute ("Condition", " '$(JarPath)' == '' "), jarPath), - new XElement (msbuild + "DotNetToolPath", new XAttribute ("Condition", " '$(DotNetToolPath)' == '' "), + new XElement (msbuild + "DotnetToolPath", new XAttribute ("Condition", " '$(DotnetToolPath)' == '' "), dotnet), CreateJreRtJarPath (msbuild, rtJarPath))); project.Save (PropertyFile.ItemSpec); diff --git a/build-tools/scripts/Prepare.targets b/build-tools/scripts/Prepare.targets index 29b4fe4cf..b13e9651a 100644 --- a/build-tools/scripts/Prepare.targets +++ b/build-tools/scripts/Prepare.targets @@ -15,7 +15,7 @@ JdksRoot="$(ProgramFiles)\Java" MakeFragmentFile="$(MSBuildThisFileDirectory)..\..\bin\Build$(Configuration)\JdkInfo.mk" MaximumJdkVersion="$(_MaxJdk)" - DotNetToolPath="$(DotNetToolPath)" + DotnetToolPath="$(DotnetToolPath)" PropertyFile="$(_TopDir)\bin\Build$(Configuration)\JdkInfo.props"> diff --git a/build-tools/scripts/jdk.mk b/build-tools/scripts/jdk.mk index 18b1fe660..74ea11577 100644 --- a/build-tools/scripts/jdk.mk +++ b/build-tools/scripts/jdk.mk @@ -45,5 +45,5 @@ endif # $(OS)=Linux $(_INCLUDE_MK) $(_INCLUDE_PROPS): bin/Build$(CONFIGURATION)/Java.Interop.BootstrapTasks.dll $(MSBUILD) $(MSBUILD_FLAGS) build-tools/scripts/jdk.targets /t:GetPreferredJdkRoot \ /p:JdksRoot="$(_JDKS_ROOT)" \ - /p:DotNetToolPath="$(DOTNET_TOOL_PATH)" \ + /p:DotnetToolPath="$(DOTNET_TOOL_PATH)" \ $(if $(JI_MAX_JDK),"/p:MaximumJdkVersion=$(JI_MAX_JDK)") diff --git a/build-tools/scripts/jdk.targets b/build-tools/scripts/jdk.targets index f43df8e8a..e71f1d921 100644 --- a/build-tools/scripts/jdk.targets +++ b/build-tools/scripts/jdk.targets @@ -6,7 +6,7 @@ JdksRoot="$(JdksRoot)" MakeFragmentFile="$(MSBuildThisFileDirectory)..\..\bin\Build$(Configuration)\JdkInfo.mk" MaximumJdkVersion="$(MaximumJdkVersion)" - DotNetToolPath="$(DotNetToolPath)" + DotnetToolPath="$(DotnetToolPath)" PropertyFile="$(MSBuildThisFileDirectory)..\..\bin\Build$(Configuration)\JdkInfo.props">