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

[Xamarin.Android.Build.Tasks] temporarily support .NET 8 in .NET 10 #9777

Merged
merged 5 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions build-tools/create-packs/Microsoft.NET.Sdk.Android.proj
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ about the various Microsoft.Android workloads.
<ReplaceFileContents
SourceFile="$(XamarinAndroidSourcePath)src\Xamarin.Android.Build.Tasks\Microsoft.NET.Sdk.Android\WorkloadManifest.in.json"
DestinationFile="$(WorkloadManifestJsonPath)"
Replacements="@WORKLOAD_VERSION@=$(WorkloadVersion);@NET_PREVIOUS_VERSION@=$(AndroidNetPreviousVersion)">
Replacements="@WORKLOAD_VERSION@=$(WorkloadVersion);@NET_PREVIOUS_VERSION@=$(AndroidNetPreviousVersion);@NET8_PREVIOUS_VERSION@=$(AndroidNet8PreviousVersion)">
</ReplaceFileContents>
<ReplaceFileContents
SourceFile="$(XamarinAndroidSourcePath)src\Xamarin.Android.Build.Tasks\Microsoft.NET.Sdk.Android\WorkloadManifest.in.targets"
DestinationFile="$(WorkloadManifestTargetsPath)"
Replacements="@NET_PREVIOUS_VERSION@=$(AndroidNetPreviousVersion)">
Replacements="@NET_PREVIOUS_VERSION@=$(AndroidNetPreviousVersion);@NET8_PREVIOUS_VERSION@=$(AndroidNet8PreviousVersion)">
</ReplaceFileContents>

<ItemGroup>
Expand Down
2 changes: 2 additions & 0 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
<!-- Previous .NET Android version -->
<MicrosoftAndroidSdkWindowsPackageVersion>35.0.24</MicrosoftAndroidSdkWindowsPackageVersion>
<AndroidNetPreviousVersion>$(MicrosoftAndroidSdkWindowsPackageVersion)</AndroidNetPreviousVersion>
<!-- To be removed before .NET 10 GA -->
<AndroidNet8PreviousVersion>34.0.147</AndroidNet8PreviousVersion>
</PropertyGroup>
<PropertyGroup>
<!-- Match the first three version numbers and append 00 -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"packs": [
"Microsoft.Android.Sdk.net10",
"Microsoft.Android.Sdk.net9",
"Microsoft.Android.Sdk.net8",
"Microsoft.Android.Ref.35",
"Microsoft.Android.Runtime.Mono.35.android-arm",
"Microsoft.Android.Runtime.Mono.35.android-arm64",
Expand All @@ -15,6 +16,8 @@
],
"platforms": [ "win-x64", "win-arm64", "linux-x64", "linux-arm64", "osx-x64", "osx-arm64" ],
"extends" : [
"microsoft-net-runtime-android-net8",
"microsoft-net-runtime-android-aot-net8",
"microsoft-net-runtime-android-net9",
"microsoft-net-runtime-android-aot-net9",
"microsoft-net-runtime-android",
Expand Down Expand Up @@ -61,6 +64,19 @@
"linux-arm64": "Microsoft.Android.Sdk.Linux"
}
},
"Microsoft.Android.Sdk.net8": {
"kind": "sdk",
"version": "@NET8_PREVIOUS_VERSION@",
"alias-to": {
"osx-x64": "Microsoft.Android.Sdk.Darwin",
"osx-arm64": "Microsoft.Android.Sdk.Darwin",
"win-x86": "Microsoft.Android.Sdk.Windows",
"win-x64": "Microsoft.Android.Sdk.Windows",
"win-arm64": "Microsoft.Android.Sdk.Windows",
"linux-x64": "Microsoft.Android.Sdk.Linux",
"linux-arm64": "Microsoft.Android.Sdk.Linux"
}
},
"Microsoft.Android.Ref.35": {
"kind": "framework",
"version": "@WORKLOAD_VERSION@"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
Condition=" $([MSBuild]::VersionEquals($(TargetFrameworkVersion), '10.0')) " />
<Import Project="Sdk.targets" Sdk="Microsoft.Android.Sdk.net9"
Condition=" $([MSBuild]::VersionEquals($(TargetFrameworkVersion), '9.0')) " />
<Import Project="Sdk.targets" Sdk="Microsoft.Android.Sdk.net8"
Condition=" $([MSBuild]::VersionEquals($(TargetFrameworkVersion), '8.0')) " />
<Import Project="Eol.targets" Sdk="Microsoft.Android.Sdk.net10"
Condition=" $([MSBuild]::VersionLessThanOrEquals($(TargetFrameworkVersion), '8.0')) " />
Condition=" $([MSBuild]::VersionLessThanOrEquals($(TargetFrameworkVersion), '7.0')) " />
</ImportGroup>

<ItemGroup Condition=" '$(TargetPlatformIdentifier)' == 'android' and $([MSBuild]::VersionEquals($(TargetFrameworkVersion), '9.0')) ">
Expand All @@ -16,7 +18,15 @@
/>
</ItemGroup>

<ItemGroup Condition=" '$(TargetFrameworkIdentifier)' == '.NETCoreApp' and $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '9.0')) ">
<ItemGroup Condition=" '$(TargetPlatformIdentifier)' == 'android' and $([MSBuild]::VersionEquals($(TargetFrameworkVersion), '8.0')) ">
<KnownFrameworkReference
Update="Microsoft.Android"
LatestRuntimeFrameworkVersion="@NET8_PREVIOUS_VERSION@"
TargetingPackVersion="@NET8_PREVIOUS_VERSION@"
/>
</ItemGroup>

<ItemGroup Condition=" '$(TargetFrameworkIdentifier)' == '.NETCoreApp' and $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '8.0')) ">
<SdkSupportedTargetPlatformIdentifier Include="android" DisplayName="Android" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ public void DotNetNew ([Values ("android", "androidlib", "android-bindinglib", "
}

static readonly object[] DotNetPackTargetFrameworks = new object[] {
new object[] {
"net8.0",
"android",
34,
},
new object[] {
"net9.0",
"android",
Expand Down Expand Up @@ -145,6 +150,11 @@ public String Say (String quote) {
}

static readonly object[] DotNetTargetFrameworks = new object[] {
new object[] {
"net8.0",
"android",
34,
},
new object[] {
"net9.0",
"android",
Expand Down Expand Up @@ -200,7 +210,7 @@ public void DotNetPublish ([Values (false, true)] bool isRelease, [ValueSource(n
var apiLevel = (int)data[2];

//FIXME: will revisit this in a future PR
if (dotnetVersion == "net9.0") {
if (dotnetVersion != "net10.0") {
Assert.Ignore ("error NETSDK1185: The Runtime Pack for FrameworkReference 'Microsoft.Android.Runtime.34.android-arm' was not available. This may be because DisableTransitiveFrameworkReferenceDownloads was set to true.");
}

Expand Down
6 changes: 4 additions & 2 deletions tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -897,10 +897,12 @@ public void CheckResouceIsOverridden ()

[Test]
[Category ("WearOS")]
public void DotNetInstallAndRunPreviousSdk ([Values (false, true)] bool isRelease)
public void DotNetInstallAndRunPreviousSdk (
[Values (false, true)] bool isRelease,
[Values ("net8.0-android", "net9.0-android")] string targetFramework)
{
var proj = new XamarinFormsAndroidApplicationProject () {
TargetFramework = "net9.0-android",
TargetFramework = targetFramework,
IsRelease = isRelease,
EnableDefaultItems = true,
};
Expand Down
Loading