public IEnumerable <ApkEntry> GetApkEntries() { var items = new List <ApkEntry>(); int index = 1; using (var zf = new ReadOnlyZipFile(FileSystemPath)) { items.AddRange(zf.Entries.Select(entry => new ApkEntry(entry, index++, ResourceFolder))); } if (Directory.Exists(ResourceFolder)) { var files = FolderUtility.GetFilesRecursively(ResourceFolder, "*.*", string.Format("{0}build{0}apk", Path.DirectorySeparatorChar)); items.AddRange( files.Where( x => items.FirstOrDefault(y => y.FileSystemPath.Equals(x, StringComparison.OrdinalIgnoreCase)) == null).Select(path => new ApkEntry(path, ResourceFolder))); items.RemoveAll(x => x.RelativePath.EndsWith("apktool.yml", StringComparison.OrdinalIgnoreCase)); items.Sort((a, b) => string.Compare(a.RelativePath, b.RelativePath)); ChangePosition(items, "classes.dex", 0); ChangePosition(items, "AndroidManifest.xml", 0); ChangePosition(items, "META-INF/CERT.RSA", 0); ChangePosition(items, "META-INF/CERT.SF", 0); ChangePosition(items, "META-INF/MANIFEST.MF", 0); ChangePosition(items, "resources.arsc", -1); } var publicXmlFile = Path.Combine(ResourceFolder, "res", "values", "public.xml"); if (File.Exists(publicXmlFile)) { var xdoc = XDocument.Load(publicXmlFile); foreach (var item in items) { string type = ""; if (item.RelativePath.IndexOf("drawable", StringComparison.OrdinalIgnoreCase) > -1) { type = "drawable"; } else if (item.RelativePath.IndexOf("raw", StringComparison.OrdinalIgnoreCase) > -1) { type = "raw"; } if (type.Length > 0) { var name = Path.GetFileNameWithoutExtension(item.FileSystemPath) ?? ""; name = name.EndsWith(".9") ? name.Substring(0, name.Length - 2) : name; var xnode = xdoc.Descendants("public").FirstOrDefault(x => x.Attribute("type").Value == type && x.Attribute("name").Value == name); if (xnode != null) { item.ResourceId = xnode.Attribute("id").Value; } } } } return(items.ToArray()); }
private string CheckLocationsOfDependency(string additionalDependency) { string path = LocationsOfDependencies.FirstOrDefault(x => File.Exists(Path.Combine(x, additionalDependency))); if (path != null) { return(GetFileNameProperCasing(path, additionalDependency.ToUpperInvariant())); } string[] files = FolderUtility.GetFilesRecursively(ProjectPath, additionalDependency, _rsprojPathExclusion).ToArray(); if (files.Length == 0) { return(null); } return(Path.GetFileName(files[0])); }