Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[build] Target net7.0. #988

Merged
merged 5 commits into from
May 31, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
<_OutputPath>$(MSBuildThisFileDirectory)bin\Build$(Configuration)\</_OutputPath>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
<ProduceReferenceAssemblyInOutDir>true</ProduceReferenceAssemblyInOutDir>

<DotNetTargetFrameworkVersion>7.0</DotNetTargetFrameworkVersion>
<DotNetTargetFramework>net$(DotNetTargetFrameworkVersion)</DotNetTargetFramework>
<!-- Used for command-line utilities -->
<DotNetStableTargetFramework>net6.0</DotNetStableTargetFramework>
<!--
Workaround for https://github.com/NuGet/Home/issues/6461 (VSWin Only)
Even though we don't build NuGet packages, it still attempts to build the NuGet package name, which includes
Expand Down Expand Up @@ -69,7 +72,7 @@
<ToolOutputFullPath>$(MSBuildThisFileDirectory)bin\$(Configuration)-$(TargetFramework.ToLowerInvariant())\</ToolOutputFullPath>
<TestOutputFullPath>$(MSBuildThisFileDirectory)bin\Test$(Configuration)-$(TargetFramework.ToLowerInvariant())\</TestOutputFullPath>
<UtilityOutputFullPath Condition=" '$(UtilityOutputFullPathCoreApps)' != '' ">$(UtilityOutputFullPathCoreApps)</UtilityOutputFullPath>
<UtilityOutputFullPath Condition=" '$(UtilityOutputFullPathCoreApps)' == '' ">$(ToolOutputFullPath)</UtilityOutputFullPath>
<UtilityOutputFullPath Condition=" '$(UtilityOutputFullPathCoreApps)' == '' ">$(MSBuildThisFileDirectory)bin\$(Configuration)-$(DotNetStableTargetFramework)\</UtilityOutputFullPath>
<RollForward>Major</RollForward>
<JIUtilityVersion>$(JINetToolVersion)</JIUtilityVersion>
<JICoreLibVersion>$(JINetCoreLibVersion)</JICoreLibVersion>
Expand Down Expand Up @@ -118,9 +121,11 @@
meaning we can't build on VS2019.

Ignore CS8032 so that we can build on VS2019.

JniEnvironment.g.cs(34,8): error CS8981: The type name 'jobject' only contains lower-cased ascii characters. Such names may become reserved for the language.
-->
<PropertyGroup>
<NoWarn>$(NoWarn);CS8032</NoWarn>
<NoWarn>$(NoWarn);CS8032;CS8981</NoWarn>
</PropertyGroup>

<!-- The net6.0 versions of these are stricter and require overloads not available in .NET Framework, so start with just .NET Framework -->
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ TESTS = \
bin/Test$(CONFIGURATION)/Xamarin.SourceWriter-Tests.dll

NET_TESTS = \
bin/Test$(CONFIGURATION)-net6.0/Java.Base-Tests.dll
bin/Test$(CONFIGURATION)-net7.0/Java.Base-Tests.dll

PTESTS = \
bin/Test$(CONFIGURATION)/Java.Interop-PerformanceTests.dll
Expand Down Expand Up @@ -127,7 +127,7 @@ run-tests: $(TESTS) bin/Test$(CONFIGURATION)/$(JAVA_INTEROP_LIB)
$(foreach t,$(TESTS), $(call RUN_TEST,$(t),1)) \
exit $$r;

run-net-tests: $(NET_TESTS) bin/Test$(CONFIGURATION)-net6.0/$(JAVA_INTEROP_LIB)
run-net-tests: $(NET_TESTS) bin/Test$(CONFIGURATION)-net7.0/$(JAVA_INTEROP_LIB)
r=0; \
$(foreach t,$(NET_TESTS), dotnet test $(t) || r=1) \
exit $$r;
Expand Down
11 changes: 4 additions & 7 deletions build-tools/automation/azure-pipelines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ variables:
RunningOnCI: true
Build.Configuration: Release
MaxJdkVersion: 8
DotNetCoreVersion: 6.0.202
DotNetCoreVersion: 7.0.100-preview.4.22252.9
DotNetTargetFramework: net7.0
NetCoreTargetFrameworkPathSuffix: -$(DotNetTargetFramework)
1ESWindowsPool: AzurePipelines-EO
1ESWindowsImage: AzurePipelinesWindows2022compliant
1ESMacPool: Azure Pipelines
1ESMacImage: internal-macos-11
NetCoreTargetFrameworkPathSuffix: -net6.0
VSInstallRoot: C:\Program Files\Microsoft Visual Studio\2022\Enterprise

jobs:
Expand Down Expand Up @@ -136,11 +137,7 @@ jobs:
boots https://download.mono-project.com/archive/6.12.0/macos-10-universal/MonoFramework-MDK-6.12.0.145.macos10.xamarin.universal.pkg
displayName: Install Mono

- script: make prepare CONFIGURATION=$(Build.Configuration) JI_MAX_JDK=$(MaxJdkVersion)
displayName: make prepare

- script: make all CONFIGURATION=$(Build.Configuration) JI_MAX_JDK=$(MaxJdkVersion)
displayName: make all
- template: templates\core-build.yaml

- script: |
r=0
Expand Down
8 changes: 4 additions & 4 deletions build-tools/automation/templates/core-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ steps:
condition: or(eq('${{ parameters.runNativeDotnetTests }}', 'true'), eq('${{ parameters.runNativeTests }}', 'true'))
inputs:
command: test
testRunTitle: Java.Interop (net6.0 - ${{ parameters.platformName }})
testRunTitle: Java.Interop ($(DotNetTargetFramework) - ${{ parameters.platformName }})
arguments: bin/Test$(Build.Configuration)$(NetCoreTargetFrameworkPathSuffix)/Java.Interop-Tests.dll
continueOnError: true

Expand Down Expand Up @@ -122,11 +122,11 @@ steps:
continueOnError: true

- task: DotNetCoreCLI@2
displayName: 'Tests: Java.Interop-Performance-net6.0'
displayName: 'Tests: Java.Interop-Performance-$(DotNetTargetFramework)'
condition: eq('${{ parameters.runNativeTests }}', 'true')
inputs:
command: test
testRunTitle: Java.Interop-Performance (net6.0 - ${{ parameters.platformName }})
testRunTitle: Java.Interop-Performance ($(DotNetTargetFramework) - ${{ parameters.platformName }})
arguments: bin/Test$(Build.Configuration)$(NetCoreTargetFrameworkPathSuffix)/Java.Interop-PerformanceTests.dll
continueOnError: true

Expand All @@ -135,7 +135,7 @@ steps:
condition: or(eq('${{ parameters.runNativeDotnetTests }}', 'true'), eq('${{ parameters.runNativeTests }}', 'true'))
inputs:
command: test
testRunTitle: Java.Base (net6.0 - ${{ parameters.platformName }})
testRunTitle: Java.Base ($(DotNetTargetFramework) - ${{ parameters.platformName }})
arguments: bin/Test$(Build.Configuration)$(NetCoreTargetFrameworkPathSuffix)/Java.Base-Tests.dll
continueOnError: true

Expand Down
2 changes: 1 addition & 1 deletion build-tools/jnienv-gen/jnienv-gen.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net472;net6.0</TargetFrameworks>
<TargetFrameworks>net472;$(DotNetTargetFramework)</TargetFrameworks>
<IsPackable>false</IsPackable>
<IntermediateOutputPath>$(BaseIntermediateOutputPath)$(Configuration)\$(TargetFramework.ToLowerInvariant())\</IntermediateOutputPath>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion samples/Hello/Hello.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>$(DotNetTargetFramework)</TargetFramework>
<OutputType>Exe</OutputType>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Nullable>enable</Nullable>
Expand Down
2 changes: 1 addition & 1 deletion src/Java.Base/Java.Base.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0</TargetFrameworks>
<TargetFrameworks>$(DotNetTargetFramework)</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Nullable>enable</Nullable>
<!-- TODO: CS0108 is due to e.g. interfaces re-abstracting default interface methods -->
Expand Down
2 changes: 1 addition & 1 deletion src/Java.Interop.Export/Java.Interop.Export.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;$(DotNetTargetFramework)</TargetFrameworks>
<LangVersion>8.0</LangVersion>
<ProjectGuid>{B501D075-6183-4E1D-92C9-F7B5002475B1}</ProjectGuid>
<Nullable>enable</Nullable>
Expand Down
4 changes: 2 additions & 2 deletions src/Java.Interop/Java.Interop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
<Import Condition="Exists ('$(XAConfigPath)')" Project="$(XAConfigPath)" />
<!--
NOTE: in xamarin-android, this project gets built by xabuild in Xamarin.Android-Tests.sln
Exclude net6.0, because xabuild cannot build net5.0 or higher
Exclude net6.0+, because xabuild cannot build net5.0 or higher
-->
<PropertyGroup Condition=" '$(XABuild)' == 'true' ">
<TargetFramework>netstandard2.0</TargetFramework>
<_JniEnvSkipGetTargetFrameworkProperties>true</_JniEnvSkipGetTargetFrameworkProperties>
<_JniEnvAdditionalProperties>TargetFramework=net472</_JniEnvAdditionalProperties>
</PropertyGroup>
<PropertyGroup Condition=" '$(XABuild)' != 'true' ">
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;$(DotNetTargetFramework)</TargetFrameworks>
</PropertyGroup>
<PropertyGroup>
<NoWarn>$(NoWarn);1591</NoWarn>
Expand Down
4 changes: 2 additions & 2 deletions src/Java.Runtime.Environment/Java.Runtime.Environment.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;$(DotNetTargetFramework)</TargetFrameworks>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\product.snk</AssemblyOriginatorKeyFile>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>8.0</LangVersion>
<LangVersion>9.0</LangVersion>
<Nullable>enable</Nullable>
<MSBuildWarningsAsMessages>NU1702</MSBuildWarningsAsMessages>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;$(DotNetTargetFramework)</TargetFrameworks>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This "confuses" me, and I'm not sure what's going on. $(DotNetTargetFramework) is net7.0, thus I would expect bin/Debug-net7.0/Xamarin.Android.Tools.Bytecode.dll to be a file that exists after a build.

However, it doesn't exist; instead, I have bin/Debug-net6.0/Xamarin.Android.Tools.Bytecode.dll, which is a copy of the .NET Standard 2.0 build, which is weird.

Meaning, as a consequence of this change, e.g. the net6.0 class-parse.dll now references the .NET Standard 2.0 build of Xamarin.Android.Tools.Bytecode.dll (v0.2.0.11), whereas before this change it referenced the net6.0 build, 7.0.0.7.

In this case that likely doesn't matter, as there's no #if NET in Xamarin.Android.Tools.Bytecode.dll, but if that ever changed…

I suspect what we actually want/need is to instead add a 3rd $(TargetFramework) value in many of these places, instead of replacing net6.0 with net7.0, a'la:

<TargetFrameworks>netstandard2.0;$(DotNetStableTargetFramework);$(DotNetTargetFramework)</TargetFrameworks

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or this is a good reason to make everything target net7.0 instead of some things still targeting net6.0.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've moved everything back to target net7.0.

<LangVersion>8.0</LangVersion>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\product.snk</AssemblyOriginatorKeyFile>
Expand Down
2 changes: 1 addition & 1 deletion src/java-interop/java-interop.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.Build.NoTargets">
<PropertyGroup>
<TargetFrameworks>net472;net6.0</TargetFrameworks>
<TargetFrameworks>net472;$(DotNetTargetFramework)</TargetFrameworks>
<OutputPath>$(ToolOutputFullPath)</OutputPath>
<JNIEnvGenPath>$(BuildToolOutputFullPath)</JNIEnvGenPath>
<OutputName>java-interop</OutputName>
Expand Down
2 changes: 1 addition & 1 deletion tests/Java.Base-Tests/Java.Base-Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0</TargetFrameworks>
<TargetFrameworks>$(DotNetTargetFramework)</TargetFrameworks>
<RootNamespace>Java.BaseTests</RootNamespace>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Nullable>enable</Nullable>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net472;net6.0</TargetFrameworks>
<TargetFrameworks>net472;$(DotNetTargetFramework)</TargetFrameworks>
<IsPackable>false</IsPackable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
Expand Down
6 changes: 3 additions & 3 deletions tests/Java.Interop-Tests/Java.Interop-Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net472;net6.0</TargetFrameworks>
<TargetFrameworks>net472;$(DotNetTargetFramework)</TargetFrameworks>
<IsPackable>false</IsPackable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>9.0</LangVersion>
Expand All @@ -11,7 +11,7 @@
<OutputPath>$(TestOutputFullPath)</OutputPath>
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
<PropertyGroup Condition=" '$(TargetFramework)' != 'net472' ">
<DefineConstants>$(DefineConstants);NO_MARSHAL_MEMBER_BUILDER_SUPPORT;NO_GC_BRIDGE_SUPPORT</DefineConstants>
</PropertyGroup>

Expand All @@ -35,7 +35,7 @@
<ProjectReference Include="..\TestJVM\TestJVM.csproj" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' != 'net6.0' ">
<ItemGroup Condition=" '$(TargetFramework)' == 'net472' ">
<ProjectReference Include="..\..\src\Java.Interop.Export\Java.Interop.Export.csproj" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net472;net6.0</TargetFrameworks>
<TargetFrameworks>net472;$(DotNetTargetFramework)</TargetFrameworks>
<IsPackable>false</IsPackable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net472;net6.0</TargetFrameworks>
<TargetFrameworks>net472;$(DotNetTargetFramework)</TargetFrameworks>
<IsPackable>false</IsPackable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net472;net6.0</TargetFrameworks>
<TargetFrameworks>net472;$(DotNetTargetFramework)</TargetFrameworks>
<RootNamespace>Java.Interop.Tools.Common_Tests</RootNamespace>
<IsPackable>false</IsPackable>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net472;net6.0</TargetFrameworks>
<TargetFrameworks>net472;$(DotNetTargetFramework)</TargetFrameworks>
<IsPackable>false</IsPackable>
<DefineConstants>$(DefineConstants);HAVE_CECIL;JCW_ONLY_TYPE_NAMES</DefineConstants>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net472;net6.0</TargetFrameworks>
<TargetFrameworks>net472;$(DotNetTargetFramework)</TargetFrameworks>
<IsPackable>False</IsPackable>
</PropertyGroup>
<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net472;net6.0</TargetFrameworks>
<TargetFrameworks>net472;$(DotNetTargetFramework)</TargetFrameworks>
<IsPackable>false</IsPackable>
<RootNamespace>Java.Interop.Tools.JavaTypeSystem.Tests</RootNamespace>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion tests/TestJVM/TestJVM.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net472;net6.0</TargetFrameworks>
<TargetFrameworks>net472;$(DotNetTargetFramework)</TargetFrameworks>
<LangVersion>8.0</LangVersion>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net472;net6.0</TargetFrameworks>
<TargetFrameworks>net472;$(DotNetTargetFramework)</TargetFrameworks>
<IsPackable>false</IsPackable>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net472;net6.0</TargetFrameworks>
<TargetFrameworks>net472;$(DotNetTargetFramework)</TargetFrameworks>
<IsPackable>false</IsPackable>
<LangVersion>8.0</LangVersion>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net472;net6.0</TargetFrameworks>
<TargetFrameworks>net472;$(DotNetTargetFramework)</TargetFrameworks>
<IsPackable>false</IsPackable>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion tests/generator-Tests/generator-Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net472;net6.0</TargetFrameworks>
<TargetFrameworks>net472;$(DotNetTargetFramework)</TargetFrameworks>
<IsPackable>false</IsPackable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>8.0</LangVersion>
Expand Down
4 changes: 2 additions & 2 deletions tests/invocation-overhead/invocation-overhead.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net472;net6.0</TargetFrameworks>
<TargetFrameworks>net472;$(DotNetTargetFramework)</TargetFrameworks>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<AppendTargetFrameworkToOutputPath>True</AppendTargetFrameworkToOutputPath>
<DefineConstants>FEATURE_JNIENVIRONMENT_JI_INTPTRS;FEATURE_JNIENVIRONMENT_JI_PINVOKES;FEATURE_JNIENVIRONMENT_SAFEHANDLES;FEATURE_JNIENVIRONMENT_XA_INTPTRS </DefineConstants>
<DefineConstants Condition=" '$(TargetFramework)' == 'net6.0' ">$(DefineConstants);FEATURE_JNIENVIRONMENT_JI_FUNCTION_POINTERS</DefineConstants>
<DefineConstants Condition=" '$(TargetFramework)' != 'net472' ">$(DefineConstants);FEATURE_JNIENVIRONMENT_JI_FUNCTION_POINTERS</DefineConstants>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion tests/invocation-overhead/invocation-overhead.targets
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
Targets="_Run_net472"
/>
<MSBuild Projects="$(MSBuildThisFileDirectory)invocation-overhead.csproj"
Properties="TargetFramework=net6.0"
Properties="TargetFramework=$(DotNetTargetFramework)"
Targets="_Run_netcoreapp"
/>
</Target>
Expand Down
2 changes: 1 addition & 1 deletion tests/logcat-parse-Tests/logcat-parse-Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net472;net6.0</TargetFrameworks>
<TargetFrameworks>net472;$(DotNetTargetFramework)</TargetFrameworks>
<IsPackable>false</IsPackable>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion tools/class-parse/class-parse.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net472;net6.0</TargetFrameworks>
<TargetFrameworks>net472;$(DotNetStableTargetFramework)</TargetFrameworks>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made a thing like $(DotNetStableTargetFramework) in xamarin-android for console apps that are used during our build. Should utilities we ship like class-parse actually build against 7? It is invoked from MSBuild in customer projects, but they should have a .NET 7 SDK.

We can also wait and update these later.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figured $(DotNetStableTargetFramework) would also be useful in JI for certain projects, but using it more widely was a bit of a hassle. Keeping the tools that XA ships on a stable .NET version gives us the flexibility to not require a system wide .NET 7 install in XA for now. If we bump these to net7.0 XA will require a global net7.0 install, or we'll need to update our build tasks to run the tool with our local dotnet install. I don't mind bumping these to net7.0 now but I didn't see a strong need to do so, but maybe I am not considering something.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with whatever is easiest for now, but we should endeavor to get everything we ship running on .NET 7 previews since that is how our customers will eventually receive it. We need to find any issues caused by .NET 7 before they do. 😁

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

xamarin-android/main is already running these on .NET 7, they just have a TargetFramework of net6.0.

If you look at a .binlog of one of our MSBuild tests, it's using a local .NET 7 SDK we provision at ./bin/Release/dotnet/dotnet.

These definitely work on 7, because 6 isn't in here at all:

image

image

Copy link
Member

@pjcollins pjcollins May 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't look too closely, but I think the AndroidDotnetToolTask that runs tools like generator and class parse only uses the dotnet that is found in path? In our XA build case where we test out of a "sandboxed" location I think we end running these tools with the latest version installed system wide. We may want to update that task to try to detect and use the dotnet path that the project is being built from, assuming this is the case. I can investigate this further outside of this PR though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there must be some logic when you Process.Start("dotnet") from inside a dotnet process, for example dotnet run just does this:

https://github.com/dotnet/sdk/blob/ad1ca90ad286288970a4ae1ec77e85848fef5a24/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets#L869-L877

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not quite sure, previous XA PR builds testing these changes had issues running class-parse and other tools because the XA test environments no longer have NET 7 installed system wide. That blob also mentions an old unresolved issue that seems related. I put up dotnet/android#7038 for now, we can discuss this further over there.

I'm going to revert the $(DotNetStableTargetFramework) changes in this PR.

<OutputType>Exe</OutputType>
</PropertyGroup>

Expand Down
4 changes: 2 additions & 2 deletions tools/generator/generator.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net472;net6.0</TargetFrameworks>
<TargetFrameworks>net472;$(DotNetStableTargetFramework)</TargetFrameworks>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same with this one, should it build for 7?

<OutputType>Exe</OutputType>
<DefineConstants>$(DefineConstants);GENERATOR;HAVE_CECIL;JCW_ONLY_TYPE_NAMES</DefineConstants>
<LangVersion>8.0</LangVersion>
Expand Down Expand Up @@ -43,7 +43,7 @@

<ItemGroup>
<None Condition=" '$(TargetFramework)' == 'net472' " Include="$(PkgMono_Options)\lib\net40\Mono.Options.pdb" CopyToOutputDirectory="PreserveNewest" />
<None Condition=" '$(TargetFramework)' == 'net6.0' " Include="$(PkgMono_Options)\lib\netstandard2.0\Mono.Options.pdb" CopyToOutputDirectory="PreserveNewest" />
<None Condition=" '$(TargetFramework)' != 'net472' " Include="$(PkgMono_Options)\lib\netstandard2.0\Mono.Options.pdb" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading