Skip to content

Commit 4d0cba6

Browse files
[build] target net6.0 instead of netcoreapp3.1 (#829)
Context: dotnet/android#5891 Context: dotnet/android@e59f649 xamarin/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. Update all appropriate `$(TargetFrameworks)` values so that `net6.0` is used instead of `netcoreapp3.1`. Update `global.json` so that a Prerelease .NET 6 SDK is used, and use `boots` to install the preview version of Mono which supports targeting `net6.0`.
1 parent 9444570 commit 4d0cba6

File tree

23 files changed

+59
-28
lines changed

23 files changed

+59
-28
lines changed

Directory.Build.props

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<AppendTargetFrameworkToOutputPath Condition=" '$(AppendTargetFrameworkToOutputPath)' == '' ">False</AppendTargetFrameworkToOutputPath>
2828
<BaseIntermediateOutputPath Condition=" '$(BaseIntermediateOutputPath)' == '' ">obj\</BaseIntermediateOutputPath>
2929
</PropertyGroup>
30-
<PropertyGroup Condition=" '$(TargetFramework)' != '' And $(TargetFramework.StartsWith ('netcoreapp')) ">
30+
<PropertyGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
3131
<JIBuildingForNetCoreApp>True</JIBuildingForNetCoreApp>
3232
</PropertyGroup>
3333
<PropertyGroup Condition=" '$(JIBuildingForNetCoreApp)' == 'True' ">
@@ -50,6 +50,7 @@
5050
<XamarinAndroidToolsDirectory Condition=" '$(XamarinAndroidToolsDirectory)' == '' ">$(MSBuildThisFileDirectory)external\xamarin-android-tools</XamarinAndroidToolsDirectory>
5151
</PropertyGroup>
5252
<PropertyGroup>
53+
<DotnetToolPath Condition=" '$(DotnetToolPath)' == '' ">dotnet</DotnetToolPath>
5354
<CmakePath Condition=" '$(CmakePath)' == '' ">cmake</CmakePath>
5455
<GradleHome Condition=" '$(GradleHome)' == '' ">$(MSBuildThisFileDirectory)build-tools\gradle</GradleHome>
5556
<GradleWPath Condition=" '$(GradleWPath)' == '' ">$(GradleHome)\gradlew</GradleWPath>
@@ -67,7 +68,7 @@
6768
<Runtime Condition="'$(OS)' != 'Windows_NT'">mono</Runtime>
6869
<_JNIEnvGenPath Condition=" '$(JIBuildingForNetCoreApp)' == 'True' ">$(BuildToolOutputFullPath)jnienv-gen.dll</_JNIEnvGenPath>
6970
<_JNIEnvGenPath Condition=" '$(JIBuildingForNetCoreApp)' != 'True' ">$(BuildToolOutputFullPath)jnienv-gen.exe</_JNIEnvGenPath>
70-
<_RunJNIEnvGen Condition=" '$(JIBuildingForNetCoreApp)' == 'True' ">dotnet "$(_JNIEnvGenPath)"</_RunJNIEnvGen>
71+
<_RunJNIEnvGen Condition=" '$(JIBuildingForNetCoreApp)' == 'True' ">$(DotnetToolPath) "$(_JNIEnvGenPath)"</_RunJNIEnvGen>
7172
<_RunJNIEnvGen Condition=" '$(JIBuildingForNetCoreApp)' != 'True' ">$(Runtime) "$(_JNIEnvGenPath)"</_RunJNIEnvGen>
7273
</PropertyGroup>
7374

build-tools/Java.Interop.BootstrapTasks/Java.Interop.BootstrapTasks/JdkInfo.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ public class JdkInfo : Task
2121

2222
public string MaximumJdkVersion { get; set; }
2323

24+
public string DotnetToolPath { get; set; }
25+
2426
static Regex VersionExtractor = new Regex (@"(?<version>[\d]+(\.\d+)+)", RegexOptions.Compiled);
2527

2628
[Required]
@@ -95,6 +97,7 @@ Action<TraceLevel, string> CreateLogger ()
9597

9698
void WritePropertyFile (string javaPath, string jarPath, string javacPath, string jdkJvmPath, string rtJarPath, IEnumerable<string> includes)
9799
{
100+
var dotnet = string.IsNullOrEmpty (DotnetToolPath) ? "dotnet" : DotnetToolPath;
98101
var msbuild = XNamespace.Get ("http://schemas.microsoft.com/developer/msbuild/2003");
99102
var project = new XElement (msbuild + "Project",
100103
new XElement (msbuild + "Choose",
@@ -112,6 +115,8 @@ void WritePropertyFile (string javaPath, string jarPath, string javacPath, strin
112115
javacPath),
113116
new XElement (msbuild + "JarPath", new XAttribute ("Condition", " '$(JarPath)' == '' "),
114117
jarPath),
118+
new XElement (msbuild + "DotnetToolPath", new XAttribute ("Condition", " '$(DotnetToolPath)' == '' "),
119+
dotnet),
115120
CreateJreRtJarPath (msbuild, rtJarPath)));
116121
project.Save (PropertyFile.ItemSpec);
117122
}

build-tools/automation/azure-pipelines.yaml

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ variables:
1919
RunningOnCI: true
2020
Build.Configuration: Release
2121
MaxJdkVersion: 8
22-
DotNetCoreVersion: 5.0.103
22+
DotNetCoreVersion: 6.0.x
2323
HostedMacImage: macOS-10.15
2424
HostedWinVS2019: Hosted Windows 2019 with VS2019
25-
NetCoreTargetFrameworkPathSuffix: -netcoreapp3.1
25+
NetCoreTargetFrameworkPathSuffix: -net6.0
2626
VSInstallRoot: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise
2727

2828
jobs:
@@ -38,15 +38,13 @@ jobs:
3838

3939
- template: templates\install-dependencies.yaml
4040

41-
- task: NuGetToolInstaller@0
41+
- task: MSBuild@1
42+
displayName: MSBuild Java.Interop.sln /t:Restore
4243
inputs:
43-
versionSpec: 5.x
44+
solution: Java.Interop.sln
45+
configuration: $(Build.Configuration)
46+
msbuildArguments: /t:Restore /p:RestoreConfigFile=$(System.DefaultWorkingDirectory)\external\xamarin-android-tools\NuGet.config
4447

45-
- task: NuGetCommand@2
46-
inputs:
47-
command: custom
48-
arguments: restore external\xamarin-android-tools\Xamarin.Android.Tools.sln -ConfigFile external\xamarin-android-tools\NuGet.config
49-
5048
- task: MSBuild@1
5149
displayName: MSBuild Java.Interop.sln /t:Prepare
5250
inputs:
@@ -108,7 +106,12 @@ jobs:
108106
submodules: recursive
109107

110108
- template: templates\install-dependencies.yaml
111-
109+
110+
- script: >
111+
dotnet tool install --global boots &&
112+
boots --preview Mono
113+
displayName: Install Mono
114+
112115
- script: make prepare CONFIGURATION=$(Build.Configuration) JI_MAX_JDK=$(MaxJdkVersion)
113116
displayName: make prepare
114117

build-tools/automation/templates/install-dependencies.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ steps:
66
displayName: Use .NET Core $(DotNetCoreVersion)
77
inputs:
88
version: $(DotNetCoreVersion)
9+
includePreviewVersions: true

build-tools/jnienv-gen/jnienv-gen.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFrameworks>net472;netcoreapp3.1</TargetFrameworks>
5+
<TargetFrameworks>net472;net6.0</TargetFrameworks>
66
<IsPackable>false</IsPackable>
77
<IntermediateOutputPath>$(BaseIntermediateOutputPath)$(Configuration)\$(TargetFramework.ToLowerInvariant())\</IntermediateOutputPath>
88
</PropertyGroup>

build-tools/scripts/Prepare.targets

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
JdksRoot="$(ProgramFiles)\Java"
1616
MakeFragmentFile="$(MSBuildThisFileDirectory)..\..\bin\Build$(Configuration)\JdkInfo.mk"
1717
MaximumJdkVersion="$(_MaxJdk)"
18+
DotnetToolPath="$(DotnetToolPath)"
1819
PropertyFile="$(_TopDir)\bin\Build$(Configuration)\JdkInfo.props">
1920
<Output TaskParameter="JavaHomePath" PropertyName="_JavaSdkDirectory" />
2021
</JdkInfo>

build-tools/scripts/jdk.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,5 @@ endif # $(OS)=Linux
4545
$(_INCLUDE_MK) $(_INCLUDE_PROPS): bin/Build$(CONFIGURATION)/Java.Interop.BootstrapTasks.dll
4646
$(MSBUILD) $(MSBUILD_FLAGS) build-tools/scripts/jdk.targets /t:GetPreferredJdkRoot \
4747
/p:JdksRoot="$(_JDKS_ROOT)" \
48+
/p:DotnetToolPath="$(DOTNET_TOOL_PATH)" \
4849
$(if $(JI_MAX_JDK),"/p:MaximumJdkVersion=$(JI_MAX_JDK)")

build-tools/scripts/jdk.targets

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
JdksRoot="$(JdksRoot)"
77
MakeFragmentFile="$(MSBuildThisFileDirectory)..\..\bin\Build$(Configuration)\JdkInfo.mk"
88
MaximumJdkVersion="$(MaximumJdkVersion)"
9+
DotnetToolPath="$(DotnetToolPath)"
910
PropertyFile="$(MSBuildThisFileDirectory)..\..\bin\Build$(Configuration)\JdkInfo.props">
1011
<Output TaskParameter="JavaHomePath" PropertyName="_JavaHome"/>
1112
</JdkInfo>

global.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{
2+
"sdk": {
3+
"allowPrerelease": true
4+
},
25
"msbuild-sdks": {
36
"Microsoft.Build.NoTargets": "2.0.1"
47
}

src/Java.Interop.Export/Java.Interop.Export.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project Sdk="Microsoft.NET.Sdk">
33
<PropertyGroup>
4-
<TargetFrameworks>netstandard2.0;netcoreapp3.1</TargetFrameworks>
4+
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
55
<LangVersion>8.0</LangVersion>
66
<ProjectGuid>{B501D075-6183-4E1D-92C9-F7B5002475B1}</ProjectGuid>
77
<SignAssembly>true</SignAssembly>

0 commit comments

Comments
 (0)