Skip to content

Commit 08790d7

Browse files
[Xamarin.Android.Build.Tasks] introduce Eol.targets for .NET 6
Fixes: #8003 Add a new `Eol.targets` file to be imported for `net6.0-android` projects. It contains the necessary/minimal settings to emit the build error: Microsoft.NET.EolTargetFrameworks.targets(35,5): error NETSDK1202: The workload '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. We will probably need the latest .NET SDK to flow to us, in order to write a test. I could only test locally by editing `.targets` files in the .NET SDK.
1 parent d9938ba commit 08790d7

File tree

2 files changed

+46
-2
lines changed

2 files changed

+46
-2
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<!--
2+
***********************************************************************************************
3+
Eol.targets
4+
5+
Imported only by .NET 6 EOL projects, contains settings to force the error:
6+
7+
error NETSDK1202: The workload '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.
8+
9+
Things to note:
10+
11+
* $(WarningsAsErrors) includes NETSDK1202
12+
* Force $(TargetPlatformVersion) to just be 21.0, to make it past early error messages
13+
* _ClearMissingWorkloads prevents undesired extra error messages
14+
15+
***********************************************************************************************
16+
-->
17+
<Project InitialTargets="_ClearMissingWorkloads">
18+
<PropertyGroup>
19+
<!-- Force NETSDK1202 to be an error -->
20+
<WarningsAsErrors>$(WarningsAsErrors);NETSDK1202</WarningsAsErrors>
21+
<!--
22+
Along with @(SdkSupportedTargetPlatformVersion), prevents the error:
23+
Microsoft.NET.TargetFrameworkInference.targets(229,5):
24+
error NETSDK1140: 31.0 is not a valid TargetPlatformVersion for android. Valid versions include:
25+
-->
26+
<TargetPlatformSupported>true</TargetPlatformSupported>
27+
<TargetPlatformVersion>21.0</TargetPlatformVersion>
28+
</PropertyGroup>
29+
<ItemGroup>
30+
<SdkSupportedTargetPlatformVersion Include="21.0" />
31+
<EolWorkload Include="android" Url="https://aka.ms/maui-support-policy" />
32+
</ItemGroup>
33+
<Target Name="_ClearMissingWorkloads">
34+
<!--
35+
Prevents the error:
36+
Microsoft.NET.Sdk.ImportWorkloads.targets(38,5): error NETSDK1147:
37+
To build this project, the following workloads must be installed: wasm-tools-net6
38+
To install these workloads, run the following command: dotnet workload restore
39+
-->
40+
<ItemGroup>
41+
<MissingWorkloadPack Remove="@(MissingWorkloadPack)" />
42+
</ItemGroup>
43+
</Target>
44+
</Project>

src/Xamarin.Android.Build.Tasks/Microsoft.NET.Sdk.Android/WorkloadManifest.in.targets

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Condition=" $([MSBuild]::VersionEquals($(TargetFrameworkVersion), '8.0')) " />
55
<Import Project="Sdk.targets" Sdk="Microsoft.Android.Sdk.net7"
66
Condition=" $([MSBuild]::VersionEquals($(TargetFrameworkVersion), '7.0')) " />
7-
<Import Project="Sdk.targets" Sdk="Microsoft.Android.Sdk.net6"
7+
<Import Project="Eol.targets" Sdk="Microsoft.Android.Sdk.net8"
88
Condition=" $([MSBuild]::VersionEquals($(TargetFrameworkVersion), '6.0')) " />
99
</ImportGroup>
1010

@@ -16,7 +16,7 @@
1616
/>
1717
</ItemGroup>
1818

19-
<ItemGroup Condition=" '$(TargetFrameworkIdentifier)' == '.NETCoreApp' and $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '6.0')) ">
19+
<ItemGroup Condition=" '$(TargetFrameworkIdentifier)' == '.NETCoreApp' and $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '7.0')) ">
2020
<SdkSupportedTargetPlatformIdentifier Include="android" DisplayName="Android" />
2121
</ItemGroup>
2222
</Project>

0 commit comments

Comments
 (0)