Skip to content
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
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ logcat-*.txt
apk-sizes-*.txt
*.rawproto
*.binlog
src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.props
src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.BundledVersions.props
*.ProjectImports.zip
*~
external/monodroid/
external/mono/
Expand Down
2 changes: 2 additions & 0 deletions Configuration.props
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
<!-- Should correspond to the first value from `$(API_LEVELS)` in `build-tools/api-xml-adjuster/Makefile` -->
<AndroidFirstFrameworkVersion Condition="'$(AndroidFirstFrameworkVersion)' == ''">v4.4</AndroidFirstFrameworkVersion>
<AndroidFirstApiLevel Condition="'$(AndroidFirstApiLevel)' == ''">19</AndroidFirstApiLevel>
<!-- The min API level supported by Microsoft.Android.Sdk, should refactor/remove when this value is the same as $(AndroidFirstApiLevel) -->
<AndroidMinimumDotNetApiLevel Condition="'$(AndroidMinimumDotNetApiLevel)' == ''">21</AndroidMinimumDotNetApiLevel>
<AndroidFirstPlatformId Condition="'$(AndroidFirstPlatformId)' == ''">$(AndroidFirstApiLevel)</AndroidFirstPlatformId>
<_IsRunningNuGetRestore Condition="$(RestoreTaskAssemblyFile.EndsWith('NuGet.exe', StringComparison.InvariantCultureIgnoreCase))">True</_IsRunningNuGetRestore>
<!-- *Latest* *stable* API level binding that we support; used when building src/Xamarin.Android.Build.Tasks -->
Expand Down
2 changes: 1 addition & 1 deletion Documentation/guides/OneDotNet.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ The following instructions can be used for early preview testing.
```xml
<Project Sdk="Microsoft.Android.Sdk/10.0.100">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net5.0-android</TargetFramework>
<RuntimeIdentifier>android.21-arm64</RuntimeIdentifier>
<OutputType>Exe</OutputType>
</PropertyGroup>
Expand Down
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 ());
Copy link
Member Author

@jonathanpeppers jonathanpeppers Aug 13, 2020

Choose a reason for hiding this comment

The 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.

Copy link
Member

Choose a reason for hiding this comment

The 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 __ANDROID_29__ and such for existing code...

Copy link
Member

Choose a reason for hiding this comment

The 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?

Copy link
Member Author

Choose a reason for hiding this comment

The 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. 🤦‍♀️

Copy link
Member Author

Choose a reason for hiding this comment

The 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>

Copy link
Member

Choose a reason for hiding this comment

The 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;
}
}
}
2 changes: 1 addition & 1 deletion build-tools/automation/azure-pipelines-oss.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ variables:
PREPARE_FLAGS: PREPARE_CI=1 PREPARE_CI_PR=1
DotNetCoreVersion: 3.1.201
# Version number from: https://github.com/dotnet/installer#installers-and-binaries
DotNetCorePreviewVersion: 5.0.100-preview.7.20307.3
DotNetCorePreviewVersion: 5.0.100-rc.2.20459.1

stages:
- stage: mac_stage
Expand Down
2 changes: 1 addition & 1 deletion build-tools/automation/azure-pipelines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ variables:
NUnitConsoleVersion: 3.11.1
DotNetCoreVersion: 3.1.201
# Version number from: https://github.com/dotnet/installer#installers-and-binaries
DotNetCorePreviewVersion: 5.0.100-preview.7.20307.3
DotNetCorePreviewVersion: 5.0.100-rc.2.20459.1
HostedMacMojave: Hosted Mac Internal Mojave
HostedMac: Hosted Mac Internal
HostedWinVS2019: Hosted Windows 2019 with VS2019
Expand Down
2 changes: 2 additions & 0 deletions src/Xamarin.Android.Build.Tasks/.gitignore
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
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@
</PropertyGroup>

<Import Sdk="Microsoft.NET.Sdk" Project="Sdk.targets" />
<PropertyGroup>
<TargetPlatformSupported Condition=" '$(TargetPlatformIdentifier)' == 'Android' ">true</TargetPlatformSupported>
</PropertyGroup>

<!-- Default item includes (globs and implicit references) -->
<Import Project="Microsoft.Android.Sdk.DefaultItems.targets" />
<Import Project="Microsoft.Android.Sdk.SupportedPlatforms.props" />
<!-- Build ordering, should be imported before Xamarin.Android.Common.targets -->
<Import Project="$(MSBuildThisFileDirectory)Microsoft.Android.Sdk.BuildOrder.targets" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public static void SaveGlobalJson (string directory)
public XASdkProject (string outputType = "Exe")
{
Sdk = $"Microsoft.Android.Sdk/{SdkVersion}";
TargetFramework = "net5.0";
TargetFramework = "net5.0-android";

TargetSdkVersion = AndroidSdkResolver.GetMaxInstalledPlatform ().ToString ();
PackageName = PackageName ?? string.Format ("{0}.{0}", ProjectName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ protected DotNetXamarinProject (string debugConfigurationName = "Debug", string
SetProperty ("AssemblyName", () => AssemblyName ?? ProjectName);

if (Builder.UseDotNet) {
SetProperty ("TargetFramework", "net5.0");
SetProperty ("TargetFramework", "net5.0-android");
SetProperty ("EnableDefaultItems", "false");
SetProperty ("AppendTargetFrameworkToOutputPath", "false");
SetProperty ("AppendRuntimeIdentifierToOutputPath", "false");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask AssemblyFile="$(BootstrapTasksAssembly)" TaskName="Xamarin.Android.Tools.BootstrapTasks.GenerateProfile" />
<UsingTask AssemblyFile="$(BootstrapTasksAssembly)" TaskName="Xamarin.Android.Tools.BootstrapTasks.GenerateSupportedPlatforms" />
<UsingTask AssemblyFile="$(BootstrapTasksAssembly)" TaskName="Xamarin.Android.Tools.BootstrapTasks.UnzipDirectoryChildren" />
<UsingTask AssemblyFile="$(PrepTasksAssembly)" TaskName="Xamarin.Android.BuildTools.PrepTasks.ReplaceFileContents" />
<UsingTask AssemblyFile="$(PrepTasksAssembly)" TaskName="Xamarin.Android.BuildTools.PrepTasks.Which" />
Expand All @@ -10,6 +11,10 @@
<PropertyGroup>
<_SharedRuntimeBuildPath Condition=" '$(_SharedRuntimeBuildPath)' == '' ">$(XAInstallPrefix)xbuild-frameworks\MonoAndroid\</_SharedRuntimeBuildPath>
<_GeneratedProfileClass>$(MSBuildThisFileDirectory)$(IntermediateOutputPath)Profile.g.cs</_GeneratedProfileClass>
<ResolveReferencesDependsOn>
$(ResolveReferencesDependsOn);
_GenerateSupportedPlatforms;
</ResolveReferencesDependsOn>
<BuildDependsOn>
_CopyNDKTools;
_GenerateXACommonProps;
Expand Down Expand Up @@ -266,6 +271,21 @@
Replacements="@PACKAGE_VERSION@=$(ProductVersion);@PACKAGE_VERSION_BUILD@=$(XAVersionCommitCount);@NDK_ARMEABI_V7_API@=$(AndroidNdkApiLevel_ArmV7a);@NDK_ARM64_V8A_API@=$(AndroidNdkApiLevel_ArmV8a);@NDK_X86_API@=$(AndroidNdkApiLevel_X86);@NDK_X86_64_API@=$(AndroidNdkApiLevel_X86_64);@BUNDLETOOL_VERSION@=$(XABundleToolVersion)">
</ReplaceFileContents>
</Target>
<Target Name="_FindAndroidApiInfo">
<ItemGroup>
<_AndroidApiInfo Include="$(XAInstallPrefix)xbuild-frameworks\MonoAndroid\*\AndroidApiInfo.xml" />
</ItemGroup>
</Target>
<Target Name="_GenerateSupportedPlatforms"
DependsOnTargets="_FindAndroidApiInfo"
Inputs="$(BootstrapTasksAssembly);$(MSBuildThisFile);@(_AndroidApiInfo)"
Outputs="Microsoft.Android.Sdk\targets\Microsoft.Android.Sdk.SupportedPlatforms.props">
<GenerateSupportedPlatforms
AndroidApiInfo="@(_AndroidApiInfo)"
MinimumApiLevel="$(AndroidMinimumDotNetApiLevel)"
OutputFile="Microsoft.Android.Sdk\targets\Microsoft.Android.Sdk.SupportedPlatforms.props"
/>
</Target>
<Target Name="_GenerateProfileClass"
BeforeTargets="CoreCompile"
Inputs="@(_SharedRuntimeAssemblies)"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.Android.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net5.0-android</TargetFramework>
<RootNamespace>Xamarin.Android.Tests.CodeBehindBuildTests</RootNamespace>
<OutputType>Exe</OutputType>
<AndroidGenerateLayoutBindings>True</AndroidGenerateLayoutBindings>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.Android.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net5.0-android</TargetFramework>
<RootNamespace>CommonSampleLibrary</RootNamespace>
<AssemblyName>CommonSampleLibrary</AssemblyName>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
Expand Down