Skip to content

Commit

Permalink
[Java.Interop.Tools.JavaCallableWrappers] fix net8.0 targeting in XA (#…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
jonathanpeppers authored Feb 23, 2024
1 parent 2197579 commit 67c079c
Showing 1 changed file with 2 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<XAConfigPath>..\..\bin\Build$(Configuration)\XAConfig.props</XAConfigPath>
</PropertyGroup>
<Import Condition="Exists ('$(XAConfigPath)')" Project="$(XAConfigPath)" />

<PropertyGroup>
<TargetFrameworks>netstandard2.0;$(DotNetTargetFramework)</TargetFrameworks>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<LangVersion>11.0</LangVersion>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
Expand All @@ -19,7 +13,8 @@

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

<PropertyGroup>
<!-- Only use $(ToolOutputFullPath) for netstandard2.0 -->
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<OutputPath>$(ToolOutputFullPath)</OutputPath>
</PropertyGroup>

Expand Down

0 comments on commit 67c079c

Please sign in to comment.