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

+3-2
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

+5
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

+13-10
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

+1
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

+1-1
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

+1
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

+1
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

+1
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

+3
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

+1-1
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>

src/Java.Interop.GenericMarshaler/Java.Interop.GenericMarshaler.csproj

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
<ProjectReference Include="..\Java.Interop\Java.Interop.csproj">
2525
<Project>{94BD81F7-B06F-4295-9636-F8A3B6BDC762}</Project>
2626
<Name>Java.Interop</Name>
27+
<SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties>
28+
<AdditionalProperties>TargetFramework=netstandard2.0</AdditionalProperties>
2729
</ProjectReference>
2830
</ItemGroup>
2931
</Project>

src/Java.Interop/Java.Interop.csproj

+14-1
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,19 @@
44
<XAConfigPath>..\..\bin\Build$(Configuration)\XAConfig.props</XAConfigPath>
55
</PropertyGroup>
66
<Import Condition="Exists ('$(XAConfigPath)')" Project="$(XAConfigPath)" />
7+
<!--
8+
NOTE: in xamarin-android, this project gets built by xabuild in Xamarin.Android-Tests.sln
9+
Exclude net6.0, because xabuild cannot build net5.0 or higher
10+
-->
11+
<PropertyGroup Condition=" '$(XABuild)' == 'true' ">
12+
<TargetFramework>netstandard2.0</TargetFramework>
13+
<_JniEnvSkipGetTargetFrameworkProperties>true</_JniEnvSkipGetTargetFrameworkProperties>
14+
<_JniEnvAdditionalProperties>TargetFramework=net472</_JniEnvAdditionalProperties>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(XABuild)' != 'true' ">
17+
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
18+
</PropertyGroup>
719
<PropertyGroup>
8-
<TargetFrameworks>netstandard2.0;netcoreapp3.1</TargetFrameworks>
920
<NoWarn>1591</NoWarn>
1021
<SignAssembly>true</SignAssembly>
1122
<AssemblyOriginatorKeyFile>..\..\product.snk</AssemblyOriginatorKeyFile>
@@ -57,6 +68,8 @@
5768
<None Include="Documentation\Java.Interop\JniEnvironment.References.xml" />
5869
<ProjectReference Include="..\..\build-tools\jnienv-gen\jnienv-gen.csproj"
5970
ReferenceOutputAssembly="false"
71+
SkipGetTargetFrameworkProperties="$(_JniEnvSkipGetTargetFrameworkProperties)"
72+
AdditionalProperties="$(_JniEnvAdditionalProperties)"
6073
/>
6174
</ItemGroup>
6275
<ItemGroup>

src/java-interop/java-interop.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.Build.NoTargets">
22
<PropertyGroup>
3-
<TargetFrameworks>net472;netcoreapp3.1</TargetFrameworks>
3+
<TargetFrameworks>net472;net6.0</TargetFrameworks>
44
<OutputPath>$(ToolOutputFullPath)</OutputPath>
55
<JNIEnvGenPath>$(BuildToolOutputFullPath)</JNIEnvGenPath>
66
<OutputName>java-interop</OutputName>

tests/Java.Interop-PerformanceTests/Java.Interop-PerformanceTests.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net472;netcoreapp3.1</TargetFrameworks>
4+
<TargetFrameworks>net472;net6.0</TargetFrameworks>
55
<IsPackable>false</IsPackable>
66
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
77
</PropertyGroup>

tests/Java.Interop-Tests/Java.Interop-Tests.csproj

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net472;netcoreapp3.1</TargetFrameworks>
4+
<TargetFrameworks>net472;net6.0</TargetFrameworks>
55
<IsPackable>false</IsPackable>
66
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
77
</PropertyGroup>
@@ -10,7 +10,7 @@
1010
<OutputPath>$(TestOutputFullPath)</OutputPath>
1111
</PropertyGroup>
1212

13-
<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">
13+
<PropertyGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
1414
<DefineConstants>$(DefineConstants);NO_MARSHAL_MEMBER_BUILDER_SUPPORT;NO_GC_BRIDGE_SUPPORT</DefineConstants>
1515
</PropertyGroup>
1616

@@ -37,7 +37,7 @@
3737
<ProjectReference Include="..\TestJVM\TestJVM.csproj" />
3838
</ItemGroup>
3939

40-
<ItemGroup Condition=" '$(TargetFramework)' != 'netcoreapp3.1' ">
40+
<ItemGroup Condition=" '$(TargetFramework)' != 'net6.0' ">
4141
<ProjectReference Include="..\..\src\Java.Interop.Export\Java.Interop.Export.csproj" />
4242
</ItemGroup>
4343

tests/TestJVM/TestJVM.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net472;netcoreapp3.1</TargetFrameworks>
4+
<TargetFrameworks>net472;net6.0</TargetFrameworks>
55
<IsPackable>false</IsPackable>
66
</PropertyGroup>
77

tests/invocation-overhead/Directory.Build.targets

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
Targets="_Run_net472"
3030
/>
3131
<MSBuild Projects="$(MSBuildThisFileDirectory)invocation-overhead.csproj"
32-
Properties="TargetFramework=netcoreapp3.1"
32+
Properties="TargetFramework=net6.0"
3333
Targets="_Run_netcoreapp"
3434
/>
3535
</Target>

tests/invocation-overhead/invocation-overhead.csproj

+1-1
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
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
77
<AppendTargetFrameworkToOutputPath>True</AppendTargetFrameworkToOutputPath>
88
<DefineConstants>FEATURE_JNIENVIRONMENT_JI_INTPTRS;FEATURE_JNIENVIRONMENT_JI_PINVOKES;FEATURE_JNIENVIRONMENT_SAFEHANDLES;FEATURE_JNIENVIRONMENT_XA_INTPTRS </DefineConstants>

tools/class-parse/class-parse.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net472;netcoreapp3.1</TargetFrameworks>
4+
<TargetFrameworks>net472;net6.0</TargetFrameworks>
55
<OutputType>Exe</OutputType>
66
</PropertyGroup>
77

tools/generator/generator.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net472;netcoreapp3.1</TargetFrameworks>
4+
<TargetFrameworks>net472;net6.0</TargetFrameworks>
55
<OutputType>Exe</OutputType>
66
<DefineConstants>$(DefineConstants);GENERATOR;HAVE_CECIL;JCW_ONLY_TYPE_NAMES</DefineConstants>
77
<LangVersion>8.0</LangVersion>

tools/jcw-gen/jcw-gen.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net472;netcoreapp3.1</TargetFrameworks>
4+
<TargetFrameworks>net472;net6.0</TargetFrameworks>
55
<OutputType>Exe</OutputType>
66
</PropertyGroup>
77

tools/logcat-parse/logcat-parse.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net472;netcoreapp3.1</TargetFrameworks>
4+
<TargetFrameworks>net472;net6.0</TargetFrameworks>
55
<OutputType>Exe</OutputType>
66
</PropertyGroup>
77

tools/param-name-importer/param-name-importer.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFrameworks>net472;netcoreapp3.1</TargetFrameworks>
3+
<TargetFrameworks>net472;net6.0</TargetFrameworks>
44
<OutputType>Exe</OutputType>
55
</PropertyGroup>
66
<PropertyGroup>

0 commit comments

Comments
 (0)