private void btn提取_Click(object sender, RoutedEventArgs e) { SetMessage("提取中...", Brushes.Blue); string apk = txtInput.Text; string outputDir = txtOutput1.Text; var files = GetLines(txtFiles.Text); if (string.IsNullOrWhiteSpace(apk) || string.IsNullOrWhiteSpace(outputDir)) { SetMessage("请输入 “目标apk”,“输出目录” 。", Brushes.Red); return; } SaveFilesConfig(); SetButtonEnabled(false); Task.Run(() => { try { Stopwatch sw = new Stopwatch(); sw.Start(); int unzipFileCount = ApkTool.Unzip(apk, files, outputDir); sw.Stop(); SetMessage($@"提取了{unzipFileCount}个文件,耗时: {sw.Elapsed:hh\:mm\:ss\.fff}", Brushes.Green); } catch (Exception ex) { SetMessage("提取失败:" + ex.Message, Brushes.Red); } finally { SetButtonEnabled(true); } }); }
public static void AssemblyApk(string inApkPath, string outApkPath, string ifsPath) { Logger.Log($"开始组装APK...\napkPath:{inApkPath},ifsPath:{ifsPath}"); ApkTool.PutPathInAPK(inApkPath, outApkPath, "assets/AssetBundles.png", ifsPath); Logger.Log($"APK组装完成"); }
private void btn打包_Click(object sender, RoutedEventArgs e) { SetMessage("打包并签名中...", Brushes.Blue); string inputApk = txtInput.Text; string inputDir = txtOutput1.Text; string outputApk = txtOutput2.Text; string filesText = txtFiles.Text; if (string.IsNullOrWhiteSpace(inputApk) || string.IsNullOrWhiteSpace(inputDir) || string.IsNullOrWhiteSpace(outputApk)) { SetMessage("请输入 “目标apk”,“输出目录”,“输出apk” 。", Brushes.Red); return; } SaveFilesConfig(); //{ // ApkTool.ZipAndSign(inputApk, inputDir, GetLines(filesText), outputApk, "key.p12"); // SetMessage($@"打包并签名成功", Brushes.Green); // return; //} SetButtonEnabled(false); Task.Run(() => { try { Stopwatch sw = new Stopwatch(); sw.Start(); int zipFileCount = ApkTool.ZipAndSign(inputApk, inputDir, GetLines(filesText), outputApk, "key.p12"); sw.Stop(); SetMessage($@"打包并签名了{zipFileCount}个文件,耗时: {sw.Elapsed:hh\:mm\:ss\.fff}", Brushes.Green); } catch (NoKeyException) { SetMessage("签名失败:未找到key.p12文件。", Brushes.Red); } catch (Exception ex) { SetMessage("打包失败:" + ex.Message.Trim(), Brushes.Red); } finally { SetButtonEnabled(true); } }); }
static void Main(string[] args) { SpaceUtil.SetTempSpace("temp"); var logFile = SpaceUtil.GetPathInTemp($"NssIntegrationStart_{DateTime.Now.ToString("yyyyMMddhhmmss")}.log"); Logger.SetLogFile("NssIntegrationStart", new LogFile(logFile)); Logger.BeginMuteConsoleOutput(); CLApp.Init("NssIntegration"); var envConfigPath = SpaceUtil.GetPathInBase($"Config{Path.DirectorySeparatorChar}EnvConfig.json"); Dictionary <string, string> dicEnvConfig = null; if (File.Exists(envConfigPath)) { JsonSerializer jsonSerializer = new JsonSerializer(); dicEnvConfig = (Dictionary <string, string>)jsonSerializer.Deserialize(new StreamReader(envConfigPath), typeof(Dictionary <string, string>)); } // 初始化各种工具类 SvnUtil.Init(() => GetEnv(envConfigPath, dicEnvConfig, "SvnBin")); ApkTool.Init(() => GetEnv(envConfigPath, dicEnvConfig, "ApkTool")); IntegrationServer.Init(() => GetEnv(envConfigPath, dicEnvConfig, "IntegrationServerAddress")); IFSUtil.Init(() => GetEnv(envConfigPath, dicEnvConfig, "IIPS")); CLApp.AddCommand(NewMethodCommand(typeof(BuildProcedure), "AssemblyApk")); CLApp.AddCommand(NewMethodCommand(typeof(BuildProcedure), "PrepareUniqueVersionJson")); CLApp.AddCommand(NewMethodCommand(typeof(BuildProcedure), "ModifyMacro")); CLApp.AddCommand(NewMethodCommand(typeof(BuildProcedure), "BuildApk")); CLApp.AddCommand(NewMethodCommand(typeof(BuildEntry), "UnpackIFS")); CLApp.AddCommand(NewMethodCommand(typeof(BuildEntry), "Build")); Logger.SetLogFile("NssIntegrationStart", null); Logger.EndMuteConsoleOutput(); CLApp.Launch(args); }