/// <summary> /// 生成版本文件 Patch /// </summary> public void generatePatch() { string ver_all = currentVerData.ver_all; string ver_patch = currentVerData.ver_patch; Console.WriteLine("开始 生成Patch :" + ver_patch); if (Directory.Exists(ver_patch)) { Directory.Delete(ver_patch, true); } foreach (var kvp in currentVerData.manifest.dict) { if (!compareVersionData.manifest.ItemEquals(kvp.Key, kvp.Value)) { string srcPath = ver_all + kvp.Value; string absoluteDestPath = ver_patch + kvp.Value; currentVerData.manifestPatch.Add(kvp.Key, kvp.Value); CopyCommand.CopyFile(srcPath, absoluteDestPath, false); } } currentVerData.manifest.SaveTo(currentVerData.ver_manifest_patch); currentVerData.manifestPatch.SaveTo(currentVerData.ver_manifestPatch); if (versionSetting.isZipVerFolderPatch) { Console.WriteLine("开始 压缩 :" + currentVerData.ver_patch_zip); ZipHelper.ZipDirectory(ver_patch, currentVerData.ver_patch_zip); } }
/// <summary> /// 生成版本文件 all /// </summary> public void generateAll() { string ver_all = currentVerData.ver_all; Console.WriteLine("开始 生成All :" + ver_all); if (Directory.Exists(ver_all)) { Directory.Delete(ver_all, true); } string[] files = Directory.GetFiles(Setting.Options.sourceRoot, "", SearchOption.AllDirectories); foreach (string file in files) { string path = file.Replace('\\', '/'); string relativePath = path.Replace(Setting.Options.sourceRoot, ""); if (Setting.Options.isIgnorePath(relativePath)) { continue; } string md5 = HashHelper.ComputeCRC32(path); string destPath = Path.GetDirectoryName(relativePath) + "/" + Path.GetFileNameWithoutExtension(relativePath) + "-" + md5 + Path.GetExtension(relativePath); destPath = destPath.Replace('\\', '/'); if (destPath.IndexOf('/') == 0) { destPath = destPath.Substring(1); } currentVerData.manifest.Add(relativePath, destPath); string absoluteDestPath = ver_all + destPath; CopyCommand.CopyFile(path, absoluteDestPath, false); Console.WriteLine(relativePath + "; " + destPath); } currentVerData.manifest.SaveTo(currentVerData.ver_manifest_all); currentVerData.manifest.SaveTo(currentVerData.ver_manifest2); }
public SKStyleData(string folderPath) { this.folderPath = folderPath; name = Path.GetFileName(folderPath); string srcSK = null; string dstSK = Setting.Options.rootExportSpineRes + "/Bones/" + name + ".sk"; List <string> srcImages = new List <string>(); List <string> dstImages = new List <string>(); DirectoryInfo directory = new DirectoryInfo(folderPath); DirectoryInfo[] infos = directory.GetDirectories(); foreach (DirectoryInfo imgDirInfo in infos) { string imgName = imgDirInfo.Name; if (srcSK == null) { srcSK = imgDirInfo.FullName + "/" + imgName + ".sk"; } string srcPng = imgDirInfo.FullName + "/" + imgName + ".png"; string dstPng = Setting.Options.rootExportSpineRes + "/" + name + "/" + imgName + ".png"; srcImages.Add(srcPng); dstImages.Add(dstPng); } if (File.Exists(srcSK)) { CopyCommand.CopyFile(srcSK, dstSK); } for (int i = 0; i < srcImages.Count; i++) { if (File.Exists(srcImages[i])) { CopyCommand.CopyFile(srcImages[i], dstImages[i]); } } }
/// <summary> /// 生成版本文件 all /// </summary> public void generateAll() { string ver_all = currentVerData.ver_all; if (versionSetting.isUseUpdateFolder) { ver_all = Setting.Options.versionRoot + "/" + versionSetting.updateFolder + "/"; } Console.WriteLine("开始 生成All :" + ver_all); Dictionary <string, string> jsList = new Dictionary <string, string>(); string[] files = Directory.GetFiles(Setting.Options.sourceRoot, "", SearchOption.AllDirectories); foreach (string file in files) { string path = file.Replace('\\', '/'); string relativePath = path.Replace(Setting.Options.sourceRoot, ""); if (Setting.Options.isIgnorePath(relativePath)) { continue; } string md5 = HashHelper.ComputeCRC32(path); string destPath = Path.GetDirectoryName(relativePath) + "/" + Path.GetFileNameWithoutExtension(relativePath) + "-" + md5 + Path.GetExtension(relativePath); destPath = destPath.Replace('\\', '/'); if (destPath.IndexOf('/') == 0) { destPath = destPath.Substring(1); } currentVerData.manifest.Add(relativePath, destPath); string absoluteDestPath = ver_all + destPath; CopyCommand.CopyFile(path, absoluteDestPath, false); if (versionSetting.isReplaceJsPath) { string exp = Path.GetExtension(relativePath); if (exp == ".js") { jsList.Add(relativePath, destPath); } } Console.WriteLine(relativePath + "; " + destPath); } currentVerData.manifest.SaveTo(ver_all + Setting.Options.versionConfig.ver_manifest); currentVerData.manifest.SaveTo(currentVerData.ver_manifest2); if (versionSetting.isReplaceJsPath) { if (jsList.ContainsKey("index.js")) { string indexHtmlPath = ver_all + "/index.html"; if (File.Exists(indexHtmlPath)) { string indexContent = File.ReadAllText(indexHtmlPath); indexContent = indexContent.Replace("\"index.js\"", jsList["index.js"]); File.WriteAllText(indexHtmlPath, indexContent); } string indexJsPath = ver_all + jsList["index.js"]; if (File.Exists(indexJsPath)) { string indexContent = File.ReadAllText(indexJsPath); foreach (var kvp in jsList) { indexContent = indexContent.Replace("\"" + kvp.Key + "\"", "\"" + kvp.Value + "\""); } File.WriteAllText(indexJsPath, indexContent); } } } }