public override bool Execute() { Utils.Logger = Log; var apkBuilder = new ApkBuilder(); apkBuilder.ProjectName = ProjectName; apkBuilder.OutputDir = OutputDir; apkBuilder.AndroidSdk = AndroidSdk; apkBuilder.AndroidNdk = AndroidNdk; apkBuilder.MinApiLevel = MinApiLevel; apkBuilder.BuildApiLevel = BuildApiLevel; apkBuilder.BuildToolsVersion = BuildToolsVersion; apkBuilder.StripDebugSymbols = StripDebugSymbols; apkBuilder.AssemblySearchPaths = AssemblySearchPaths?.Select(a => a.ItemSpec)?.ToArray(); apkBuilder.ExtraAssemblies = ExtraAssemblies?.Select(a => a.ItemSpec)?.ToArray(); (ApkBundlePath, ApkPackageId) = apkBuilder.BuildApk(SourceDir, Abi, MainLibraryFileName, MonoRuntimeHeaders); return(true); }
public override bool Execute() { string Pathify(string path) => string.IsNullOrEmpty(path) ? null : Regex.Replace( path, @"[\/\\]+", Path.DirectorySeparatorChar.ToString()); string sdkVersion = null; if (SdkVersion != null) { if (SdkVersion.StartsWith("@", StringComparison.Ordinal)) { var parts = SdkVersion.Substring(1).Split(new [] { ',' }, 2); switch (parts [0]) { case "GlobalJsonSdkVersion": sdkVersion = ReadGlobalJsonSdkVersion(Pathify(parts [1])); break; case "AssemblyInformationalVersion": sdkVersion = AssemblyInformationalVersion(parts [1]); break; default: throw new NotImplementedException($"Unable to handle SdkVersion style @{parts [0]}"); } if (sdkVersion == null) { return(false); } } } string targetFramework = null; TargetFrameworkVersion = TargetFrameworkVersion?.Trim().TrimStart('v'); if (TargetFrameworkIdentifier != null && TargetFrameworkVersion != null) { targetFramework = $"{TargetFrameworkIdentifier},Version={TargetFrameworkVersion}"; } var idParts = new List <string> (3) { Flavor }; if (!string.IsNullOrEmpty(SdkName)) { idParts.Add(SdkName); } if (!string.IsNullOrEmpty(SdkProfile)) { idParts.Add(SdkProfile); } var id = string .Join("-", idParts.Select(p => Regex.Replace(p, @"[^A-Za-z0-9]", ""))) .ToLowerInvariant(); var manifest = new JObject { [id] = JObject.FromObject(new { flavor = Flavor, order = Order, icon = Icon, appPath = Pathify(AppPath), appManagerAssembly = Pathify(AppManagerAssembly), sdk = new { name = SdkName, profile = SdkProfile, version = sdkVersion, targetFramework, assemblySearchPaths = AssemblySearchPaths?.Select(Pathify) }, optionalFeatures = OptionalFeatures }) }; var toRemove = manifest .Descendants() .Where(value => value.Type == JTokenType.Null) .Select(value => value.Parent is JProperty property ? property : value) .ToArray(); foreach (var nullToken in toRemove) { nullToken.Remove(); } Directory.CreateDirectory(Path.GetDirectoryName(ManifestOutputPath)); var workbooks = File.Exists(ManifestOutputPath) ? JObject.Parse(File.ReadAllText(ManifestOutputPath)) : new JObject(); workbooks.Merge(manifest, new JsonMergeSettings { MergeArrayHandling = MergeArrayHandling.Union }); Log.LogMessage( MessageImportance.Normal, $"Writing manifest entry ({id}): {ManifestOutputPath}"); File.WriteAllText( ManifestOutputPath, workbooks.ToString(Formatting.Indented)); return(true); }