Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
[android] add .NET 8 multi-targeting support (#50)
Browse files Browse the repository at this point in the history
Context: dotnet/android#7900

After attempted removal of .NET 6 (from .NET 8), we got the build error:

    Xamarin.Legacy.Android.targets(33,3): error : Could not resolve SDK "Microsoft.Android.Sdk.net6". Exactly one of the probing messages below indicates why we could not resolve the SDK. Investigate and resolve that message to correctly specify the SDK.
    Xamarin.Legacy.Android.targets(33,3): error :   SDK resolver "Microsoft.DotNet.MSBuildWorkloadSdkResolver" returned null.
    Xamarin.Legacy.Android.targets(33,3): error :   The NuGetSdkResolver did not resolve this SDK because there was no version specified in the project or global.json.
    Xamarin.Legacy.Android.targets(33,3): error :   MSB4276: The default SDK resolver failed to resolve SDK "Microsoft.Android.Sdk.net6" because directory "/Users/runner/work/1/s/xamarin-android/bin/Release/dotnet/sdk/8.0.100-preview.3.23163.4/Sdks/Microsoft.Android.Sdk.net6/Sdk" did not exist.

Add support for the .NET 8 SDK, I am unsure how it was working at all
before? It must have somehow imported the .NET 6 targets.
  • Loading branch information
jonathanpeppers authored Mar 20, 2023
1 parent 3489d96 commit 510e8a0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Xamarin.Legacy.Sdk/Sdk/Xamarin.Legacy.Android.targets
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
Project="../targets/Microsoft.Android.Sdk.DefaultProperties.targets"
/>
<Import
Condition=" '$(UseMicrosoftAndroidSdk)' != 'true' and ('$(UseMicrosoftAndroidSdkNet6)' == 'true' or !$([MSBuild]::VersionEquals($(TargetFrameworkVersion), '7.0')))"
Condition=" '$(UseMicrosoftAndroidSdk)' != 'true' and ('$(UseMicrosoftAndroidSdkNet6)' == 'true' or $([MSBuild]::VersionEquals($(TargetFrameworkVersion), '6.0')))"
Sdk="Microsoft.Android.Sdk.net6"
Project="../targets/Microsoft.Android.Sdk.DefaultProperties.targets"
/>
Expand All @@ -40,6 +40,11 @@
Sdk="Microsoft.Android.Sdk.net7"
Project="../targets/Microsoft.Android.Sdk.DefaultProperties.targets"
/>
<Import
Condition=" '$(UseMicrosoftAndroidSdk)' != 'true' and ('$(UseMicrosoftAndroidSdkNet8)' == 'true' or $([MSBuild]::VersionEquals($(TargetFrameworkVersion), '8.0')))"
Sdk="Microsoft.Android.Sdk.net8"
Project="../targets/Microsoft.Android.Sdk.DefaultProperties.targets"
/>
<Import Project="$(_LegacyExtensionsPath)/Xamarin/Android/Xamarin.Android.CSharp.targets" Condition=" '$(IsBindingProject)' != 'true' and '$(_FixupsNeeded)' == 'true' " />
<Import Project="$(_LegacyExtensionsPath)/Xamarin/Android/Xamarin.Android.Bindings.targets" Condition=" '$(IsBindingProject)' == 'true' and '$(_FixupsNeeded)' == 'true' " />
<Import Project="$(MSBuildExtensionsPath)/Xamarin/Android/Xamarin.Android.CSharp.targets" Condition=" '$(IsBindingProject)' != 'true' and '$(_FixupsNeeded)' != 'true' " />
Expand Down

0 comments on commit 510e8a0

Please sign in to comment.