Skip to content

Commit

Permalink
[Xamarin.Android.Build.Tasks] fix net7.0 "out of support" message (do…
Browse files Browse the repository at this point in the history
…tnet#8660)

Context: a48a9c5

When .NET 9 ships, the .NET 7 Android workload will be out of support.
We already have this behavior setup, but unfortunately the error
message is wrong:

	Microsoft.NET.EolTargetFrameworks.targets(38,5):
	error NETSDK1202: The workload 'net6.0-android' is out of support and will not receive security updates in the future.
	Please refer to https://aka.ms/maui-support-policy for more information about the support policy.
	[MauiTest.csproj::TargetFramework=net7.0-android]

It says `net6.0-android`!

In a48a9c5, we hardcoded `net6.0` to align with the iOS team, but we
can use the `$(TargetFrameworkVersion)` property (removing `v`) so we
don't have to update this line every year.

I updated a test for this scenario.
  • Loading branch information
jonathanpeppers authored Jan 25, 2024
1 parent a832dd8 commit cf1418d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Things to note:
</PropertyGroup>
<ItemGroup>
<SdkSupportedTargetPlatformVersion Include="21.0" />
<EolWorkload Include="net6.0-android" Url="https://aka.ms/maui-support-policy" />
<EolWorkload Include="net$(TargetFrameworkVersion.TrimStart('vV'))-android" Url="https://aka.ms/maui-support-policy" />
</ItemGroup>
<Target Name="_ClearMissingWorkloads">
<!--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,16 @@ public void SettingCombinations (bool isRelease, bool useInterpreter, bool publi
}

[Test]
public void EolFrameworks()
public void EolFrameworks ([Values ("net6.0-android", "net7.0-android")] string targetFramework)
{
var library = new XamarinAndroidLibraryProject () {
TargetFramework = "net6.0-android",
TargetFramework = targetFramework,
EnableDefaultItems = true,
};
var builder = CreateApkBuilder ();
builder.ThrowOnBuildFailure = false;
Assert.IsFalse (builder.Restore (library), $"{library.ProjectName} restore should fail");
Assert.IsTrue (StringAssertEx.ContainsText (builder.LastBuildOutput, "NETSDK1202"), $"{builder.BuildLogFile} should have NETSDK1202.");
Assert.IsTrue (StringAssertEx.ContainsText (builder.LastBuildOutput, $"NETSDK1202: The workload '{targetFramework}' is out of support"), $"{builder.BuildLogFile} should have NETSDK1202.");
}

[Test]
Expand Down

0 comments on commit cf1418d

Please sign in to comment.