Skip to content

Commit 67c079c

Browse files
[Java.Interop.Tools.JavaCallableWrappers] fix net8.0 targeting in XA (#1197)
Context: dotnet/android#8748 Context: 56b7eeb dotnet/android#8748 attempts to bump xamarin-android to use commit 56b7eeb, and fails to build: (CoreCompile target) -> Xamarin.Android.Build.Tasks\Utilities\MamJsonParser.cs(92,43): error CS0122: 'NotNullWhenAttribute' is inaccessible due to its protection level [Xamarin.Android.Build.Tasks\Xamarin.Android.Build.Tasks.csproj] Xamarin.Android.Build.Tasks\Utilities\MamJsonParser.cs(92,81): error CS0122: 'NotNullWhenAttribute' is inaccessible due to its protection level [Xamarin.Android.Build.Tasks\Xamarin.Android.Build.Tasks.csproj] Xamarin.Android.Build.Tasks\Utilities\MavenExtensions.cs(26,32): error CS0122: 'NotNullWhenAttribute' is inaccessible due to its protection level [Xamarin.Android.Build.Tasks\Xamarin.Android.Build.Tasks.csproj] The cause of the failure is that 56955d9 updated `Java.Interop.Tools.JavaCallableWrappers.csproj` to multitarget both netstandard2.0 and net8.0. This is nominally "fine", except that `Java.Interop.Tools.JavaCallableWrappers.csproj` *also* sets [`$(AppendTargetFrameworkToOutputPath)`][0]=false, which means that both builds use the *same* output directory. This means that the netstandard2.0 and net8.0 build outputs clobber each other -- in parallel! -- which means that the `Xamarin.Android.Build.Tasks.csproj` build doesn't reliably use the netstandard2.0 output assembly. Fix this scenario by no longer overriding the `$(AppendTargetFrameworkToOutputPath)` MSBuild property, and only setting `$(OutputPath)` to `$(ToolOutputFullPath)` for netstandard2.0 builds. Finally, remove use of `XAConfig.props`. This appears to be vestigial, as we can't find any current code that would produce this file. [0]: https://learn.microsoft.com/dotnet/core/project-sdk/msbuild-props#appendtargetframeworktooutputpath
1 parent 2197579 commit 67c079c

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

src/Java.Interop.Tools.JavaCallableWrappers/Java.Interop.Tools.JavaCallableWrappers.csproj

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<PropertyGroup>
4-
<XAConfigPath>..\..\bin\Build$(Configuration)\XAConfig.props</XAConfigPath>
5-
</PropertyGroup>
6-
<Import Condition="Exists ('$(XAConfigPath)')" Project="$(XAConfigPath)" />
7-
83
<PropertyGroup>
94
<TargetFrameworks>netstandard2.0;$(DotNetTargetFramework)</TargetFrameworks>
10-
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
115
<LangVersion>11.0</LangVersion>
126
<Nullable>enable</Nullable>
137
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
@@ -19,7 +13,8 @@
1913

2014
<Import Project="..\..\TargetFrameworkDependentValues.props" />
2115

22-
<PropertyGroup>
16+
<!-- Only use $(ToolOutputFullPath) for netstandard2.0 -->
17+
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
2318
<OutputPath>$(ToolOutputFullPath)</OutputPath>
2419
</PropertyGroup>
2520

0 commit comments

Comments
 (0)