|
| 1 | +using Nmkoder.Data; |
| 2 | +using Nmkoder.Extensions; |
| 3 | +using Nmkoder.OS; |
| 4 | +using System; |
| 5 | +using System.Collections.Generic; |
| 6 | +using System.Diagnostics; |
| 7 | +using System.IO; |
| 8 | +using System.Linq; |
| 9 | +using System.Text; |
| 10 | +using System.Threading.Tasks; |
| 11 | + |
| 12 | +namespace Nmkoder.IO |
| 13 | +{ |
| 14 | + class PackageBuild |
| 15 | + { |
| 16 | + public static async Task Run (string ver) |
| 17 | + { |
| 18 | + Logger.Log($"Packaging..."); |
| 19 | + |
| 20 | + try |
| 21 | + { |
| 22 | + Program.Cleanup(); |
| 23 | + string dir = Paths.GetOwnFolder(); |
| 24 | + string copyDir = Path.Combine(dir, $"Nmkoder{ver}"); |
| 25 | + IoUtils.DeleteIfExists(copyDir); |
| 26 | + Directory.CreateDirectory(copyDir); |
| 27 | + CopyDir(dir, copyDir, "bin"); |
| 28 | + CopyFile(dir, copyDir, Path.GetFileName(Paths.GetExe())); |
| 29 | + |
| 30 | + string path7z = @"C:\Program Files\7-Zip-Zstandard\7za.exe"; |
| 31 | + string archivePath1 = Path.Combine(dir, $"Nmkoder{ver}.7z"); |
| 32 | + string archivePath2 = Path.Combine(dir, $"Nmkoder{ver}-NoOCR.7z"); |
| 33 | + |
| 34 | + Process p1 = Process.Start(path7z, $"a {archivePath1.Wrap()} -m0=flzma2 -mx9 {copyDir.Wrap()}"); |
| 35 | + while (!p1.HasExited) await Task.Delay(100); |
| 36 | + IoUtils.TryDeleteIfExists(Path.Combine(copyDir, "bin", "SE")); |
| 37 | + Process.Start(path7z, $"a {archivePath2.Wrap()} -m0=flzma2 -mx9 {copyDir.Wrap()}"); |
| 38 | + |
| 39 | + } |
| 40 | + catch(Exception e) |
| 41 | + { |
| 42 | + Logger.Log(e.Message); |
| 43 | + } |
| 44 | + |
| 45 | + Logger.Log($"Done"); |
| 46 | + } |
| 47 | + |
| 48 | + private static void CopyFile(string baseDirSource, string baseDirTarget, string filename) |
| 49 | + { |
| 50 | + File.Copy(Path.Combine(baseDirSource, filename), Path.Combine(baseDirTarget, filename)); |
| 51 | + } |
| 52 | + |
| 53 | + private static void CopyDir (string baseDirSource, string baseDirTarget, string dirName) |
| 54 | + { |
| 55 | + IoUtils.CopyDir(Path.Combine(baseDirSource, dirName), Path.Combine(baseDirTarget, dirName)); |
| 56 | + } |
| 57 | + } |
| 58 | +} |
0 commit comments