public static void SetRuntimeIdentifiers(this IShortFormProject project, string [] androidAbis) { var abis = new List <string> (); foreach (var androidAbi in androidAbis) { if (androidAbi == "armeabi-v7a") { abis.Add("android.21-arm"); } else if (androidAbi == "arm64-v8a") { abis.Add("android.21-arm64"); } else if (androidAbi == "x86") { abis.Add("android.21-x86"); } else if (androidAbi == "x86_64") { abis.Add("android.21-x64"); } } project.SetProperty(KnownProperties.RuntimeIdentifiers, string.Join(";", abis)); }
/// <summary> /// Adds additional dependencies for Xamarin.Forms, support libraries, etc. on .NET 5+ /// to workaround the issue similar to https://github.com/mono/linker/issues/1139 /// </summary> public static void AddDotNetCompatPackages(this IShortFormProject project) { project.PackageReferences.Add(SystemCodeDom_5_0_0_preview_3_20214_6); project.PackageReferences.Add(SystemDiagnosticsEventLog_5_0_0_preview_3_20214_6); project.PackageReferences.Add(SystemDiagnosticsPerformanceCounter_5_0_0_preview_3_20214_6); project.PackageReferences.Add(SystemIOPorts_5_0_0_preview_3_20214_6); project.PackageReferences.Add(SystemSecurityPermissions_5_0_0_preview_3_20214_6); project.PackageReferences.Add(SystemThreadingAccessControl_5_0_0_preview_3_20214_6); }
public static void AddCultureResourcesToProject(IShortFormProject proj, string filename, string dataName, CultureTypes types = CultureTypes.AllCultures) { foreach (var culture in CultureInfo.GetCultures(types)) { proj.OtherBuildItems.Add(new BuildItem("EmbeddedResource", $"{filename}.{culture.Name}.resx") { TextContent = () => InlineData.ResxWithContents($"<data name=\"{dataName}\"><value>{culture.Name}</value></data>") }); } }
/// <summary> /// Sets $(AndroidSupportedAbis) or $(RuntimeIdentifiers) depending if running under dotnet /// </summary> public static void SetAndroidSupportedAbis(this IShortFormProject project, params string [] abis) { if (Builder.UseDotNet || project is XASdkProject) { project.SetRuntimeIdentifiers(abis); } else { project.SetAndroidSupportedAbis(string.Join(";", abis)); } }
/// <summary> /// Sets $(AndroidSupportedAbis) or $(RuntimeIdentifiers) depending if running under dotnet /// </summary> /// <param name="abis">A semi-colon-delimited list of ABIs</param> public static void SetAndroidSupportedAbis(this IShortFormProject project, string abis) { if (Builder.UseDotNet || project is XASdkProject) { project.SetRuntimeIdentifiers(abis.Split(';')); } else { project.SetProperty(KnownProperties.AndroidSupportedAbis, abis); } }
public static void SetRuntimeIdentifier(this IShortFormProject project, string androidAbi) { if (androidAbi == "armeabi-v7a") { project.SetProperty(KnownProperties.RuntimeIdentifier, "android.21-arm"); } else if (androidAbi == "arm64-v8a") { project.SetProperty(KnownProperties.RuntimeIdentifier, "android.21-arm64"); } else if (androidAbi == "x86") { project.SetProperty(KnownProperties.RuntimeIdentifier, "android.21-x86"); } else if (androidAbi == "x86_64") { project.SetProperty(KnownProperties.RuntimeIdentifier, "android.21-x64"); } }
public static string ToXml(IShortFormProject project) { var sb = new StringBuilder(); foreach (var pg in project.PropertyGroups) { if (pg.Properties.Count == 0) { continue; } if (string.IsNullOrEmpty(pg.Condition)) { sb.AppendLine("\t<PropertyGroup>"); } else { sb.AppendLine($"\t<PropertyGroup Condition=\"{pg.Condition}\">"); } foreach (var p in pg.Properties) { var conditon = string.IsNullOrEmpty(p.Condition) ? "" : $" Condition=\"{p.Condition}\""; sb.AppendLine($"\t\t<{p.Name}{conditon}>{p.Value ()}</{p.Name}>"); } sb.AppendLine("\t</PropertyGroup>"); } if (project.PackageReferences.Count > 0) { sb.AppendLine("\t<ItemGroup>"); foreach (var pr in project.PackageReferences) { sb.AppendLine($"\t\t<PackageReference Include=\"{pr.Id}\" Version=\"{pr.Version}\"/>"); } sb.AppendLine("\t</ItemGroup>"); } if (project.EnableDefaultItems) { // If $(EnableDefaultItems), then only OtherBuildItems are added if (project.OtherBuildItems.Count > 0) { sb.AppendLine("\t<ItemGroup>"); foreach (var bi in project.OtherBuildItems) { AppendBuildItem(sb, bi); } sb.AppendLine("\t</ItemGroup>"); } } else if (project.ItemGroupList.Count > 0) { foreach (var itemGroup in project.ItemGroupList) { if (itemGroup.Count == 0) { continue; } sb.AppendLine("\t<ItemGroup>"); foreach (var bi in itemGroup) { AppendBuildItem(sb, bi); } sb.AppendLine("\t</ItemGroup>"); } } foreach (var import in project.Imports) { var projectName = import.Project(); if (projectName != "Directory.Build.props" && projectName != "Directory.Build.targets") { sb.AppendLine($"\t<Import Project=\"{projectName}\" />"); } } return($"<Project Sdk=\"{project.Sdk}\">\r\n{sb}\r\n</Project>"); }