-
Notifications
You must be signed in to change notification settings - Fork 565
[Microsoft.Android.Sdk] use net5.0-android $(TargetFramework) #5007
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| using System.IO; | ||
| using System.Linq; | ||
| using System.Xml; | ||
| using Microsoft.Build.Framework; | ||
| using Microsoft.Build.Utilities; | ||
|
|
||
| namespace Xamarin.Android.Tools.BootstrapTasks | ||
| { | ||
| /// <summary> | ||
| /// Generates Microsoft.Android.Sdk.SupportedPlatforms.props | ||
| /// Similar to: https://github.com/dotnet/sdk/blob/18ee4eac8b3abe6d554d2e0c39d8952da0f23ce5/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.WindowsSupportedTargetPlatforms.props | ||
| /// </summary> | ||
| public class GenerateSupportedPlatforms : Task | ||
| { | ||
| /// <summary> | ||
| /// A list of AndroidApiInfo.xml files produced by Mono.Android.targets | ||
| /// </summary> | ||
| [Required] | ||
| public string [] AndroidApiInfo { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// The output file to generate | ||
| /// </summary> | ||
| [Required] | ||
| public string OutputFile { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// $(AndroidMinimumDotNetApiLevel) from Configuration.props | ||
| /// </summary> | ||
| [Required] | ||
| public int MinimumApiLevel { get; set; } | ||
|
|
||
| public override bool Execute () | ||
| { | ||
| if (AndroidApiInfo.Length == 0) { | ||
| Log.LogError ("This task requires at least one AndroidApiInfo.xml file!"); | ||
| return false; | ||
| } | ||
|
|
||
| var versions = new AndroidVersions ( | ||
| AndroidApiInfo.Select (d => Path.GetDirectoryName (d))); | ||
| var settings = new XmlWriterSettings { | ||
| OmitXmlDeclaration = true, | ||
| Indent = true, | ||
| }; | ||
| using (var writer = XmlWriter.Create (OutputFile, settings)) { | ||
|
|
||
| writer.WriteComment ($@" | ||
| *********************************************************************************************** | ||
| {Path.GetFileName (OutputFile)} | ||
|
|
||
| Specifies the supported Android platform versions for this SDK. | ||
|
|
||
| *********************************************************************************************** | ||
| "); | ||
| writer.WriteStartElement ("Project"); | ||
|
|
||
| writer.WriteStartElement ("PropertyGroup"); | ||
| writer.WriteStartElement ("TargetPlatformVersion"); | ||
| writer.WriteAttributeString ("Condition", " '$(TargetPlatformVersion)' == '' "); | ||
| writer.WriteString (versions.MaxStableVersion.ApiLevel.ToString ()); | ||
| writer.WriteEndElement (); // </TargetPlatformVersion> | ||
| writer.WriteEndElement (); // </PropertyGroup> | ||
|
|
||
| writer.WriteStartElement ("ItemGroup"); | ||
| foreach (AndroidVersion version in versions.InstalledBindingVersions | ||
| .Where (v => v.ApiLevel >= MinimumApiLevel) | ||
| .OrderBy (v => v.ApiLevel)) { | ||
| writer.WriteStartElement ("AndroidSdkSupportedTargetPlatform"); | ||
| writer.WriteAttributeString ("Include", version.ApiLevel.ToString ()); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is supposed to be the API level and not the Android OS version? As-is, this would list 29, 30 and not 10.0, 11.0.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this perhaps an opportunity to discuss where we use API level vs OS version? Though we need to keep
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we were planning to still use the API level, though I don't see that specifically mentioned in the specs (https://github.com/dotnet/designs/blob/master/accepted/2020/net5/net5.md#os-versions, https://github.com/dotnet/designs/blob/master/accepted/2020/minimum-os-version/minimum-os-version.md). @mhutch, can you comment?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The current generated file is: <Project>
<PropertyGroup>
<TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">30</TargetPlatformVersion>
</PropertyGroup>
<ItemGroup>
<AndroidSupportedTargetPlatform Include="26" />
<AndroidSupportedTargetPlatform Include="23" />
<AndroidSupportedTargetPlatform Include="19" />
<AndroidSupportedTargetPlatform Include="27" />
<AndroidSupportedTargetPlatform Include="22" />
<AndroidSupportedTargetPlatform Include="21" />
<AndroidSupportedTargetPlatform Include="30" />
<AndroidSupportedTargetPlatform Include="29" />
<AndroidSupportedTargetPlatform Include="25" />
<AndroidSupportedTargetPlatform Include="20" />
<AndroidSupportedTargetPlatform Include="28" />
<AndroidSupportedTargetPlatform Include="24" />
<SupportedTargetPlatform Condition=" '$(TargetPlatformIdentifier)' == 'Android' " Include="@(AndroidSupportedTargetPlatform)" />
</ItemGroup>
</Project>I need to drop 19 & 20, and looks like they need to be sorted, too. 🤦♀️
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Latest file is: <Project>
<PropertyGroup>
<TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">30</TargetPlatformVersion>
</PropertyGroup>
<ItemGroup>
<AndroidSupportedTargetPlatform Include="21" />
<AndroidSupportedTargetPlatform Include="22" />
<AndroidSupportedTargetPlatform Include="23" />
<AndroidSupportedTargetPlatform Include="24" />
<AndroidSupportedTargetPlatform Include="25" />
<AndroidSupportedTargetPlatform Include="26" />
<AndroidSupportedTargetPlatform Include="27" />
<AndroidSupportedTargetPlatform Include="28" />
<AndroidSupportedTargetPlatform Include="29" />
<AndroidSupportedTargetPlatform Include="30" />
<SupportedTargetPlatform Condition=" '$(TargetPlatformIdentifier)' == 'Android' " Include="@(AndroidSupportedTargetPlatform)" />
</ItemGroup>
</Project>
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dsplaisted I filed an issue on the dotnet/designs repo a while back about whether we want to use the API level or OS version for android TFMs: https://github.com/dotnet/designs/issues/136. It doesn't seem like there was a conclusion but I agree this is something that needs to be decided sooner than later. |
||
| writer.WriteEndElement (); // </AndroidSdkSupportedTargetPlatform> | ||
| } | ||
| writer.WriteStartElement ("SdkSupportedTargetPlatform"); | ||
| writer.WriteAttributeString ("Condition", " '$(TargetPlatformIdentifier)' == 'Android' "); | ||
| writer.WriteAttributeString ("Include", "@(AndroidSdkSupportedTargetPlatform)"); | ||
|
|
||
| writer.WriteEndDocument (); // </Project> | ||
| } | ||
|
|
||
| return !Log.HasLoggedErrors; | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,4 @@ | ||
| /Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.BundledVersions.props | ||
| /Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.SupportedPlatforms.props | ||
| /Xamarin.Android.Common.props | ||
| /Xamarin.Android.BuildInfo.txt |
Uh oh!
There was an error while loading. Please reload this page.