public override void Run(List <Variable> variableList) { var fileMaker = new NgFileMaker(); var app = AppName.Replace(@"\", @"").Replace(@".app", @""); Console.Write($@"Install app {app} ... "); foreach (var variable in variableList) { AppName = AppName.Replace("@(" + variable.Name + ")", variable.Value); FileName = FileName.Replace("@(" + variable.Name + ")", variable.Value); WorkingDirectory = WorkingDirectory.Replace("@(" + variable.Name + ")", variable.Value); } FileName = Environment.ExpandEnvironmentVariables(FileName); WorkingDirectory = Environment.ExpandEnvironmentVariables(WorkingDirectory); var appUninstallLoc = new System.IO.DirectoryInfo($@"/Applications/{AppName}"); fileMaker.DeleteFolder(appUninstallLoc); var process = new Process(); process.StartInfo.WorkingDirectory = WorkingDirectory; process.StartInfo.FileName = @$ "/bin/bash"; process.StartInfo.Arguments = $@"-c ""mv {FileName} /Applications/{AppName.Replace(@" ", @"\ ")}"""; process.StartInfo.Verb = "runas"; process.Start(); process.WaitForExit(); process = new Process(); process.StartInfo.WorkingDirectory = WorkingDirectory; process.StartInfo.FileName = @$ "/bin/bash"; process.StartInfo.Arguments = $@"-c ""xattr -cr /Applications/{AppName.Replace(@" ", @"\ ")}"""; process.StartInfo.Verb = "runas"; process.Start(); process.WaitForExit(); Console.WriteLine("Done"); }
public override void Run(List <Variable> variableList) { Console.Write("Extracting app ... "); foreach (var variable in variableList) { FilePath = FilePath.Replace("@(" + variable.Name + ")", variable.Value); ExtractFolder = ExtractFolder.Replace("@(" + variable.Name + ")", variable.Value); } FilePath = Environment.ExpandEnvironmentVariables(FilePath); ExtractFolder = Environment.ExpandEnvironmentVariables(ExtractFolder); var fileMaker = new NgFileMaker(); fileMaker.DeleteFolder(new DirectoryInfo(ExtractFolder)); Process process = new Process(); process.StartInfo.FileName = @$ "/bin/bash"; process.StartInfo.Arguments = $@"-c ""unzip -o -q {FilePath} -d {ExtractFolder}"""; process.StartInfo.Verb = "runas"; process.Start(); process.WaitForExit(); if (process.ExitCode != 0) { throw new Exception($@"unzip app failed."); } process = new Process(); process.StartInfo.FileName = @$ "/bin/bash"; process.StartInfo.Arguments = $@"-c ""chmod -R +r+w+x {ExtractFolder}"""; process.StartInfo.Verb = "runas"; process.Start(); process.WaitForExit(); if (process.ExitCode != 0) { throw new Exception($@"unzip app failed."); } Console.WriteLine("Done"); }
public override void Run(List <Variable> variableList) { var fileMaker = new NgFileMaker(); Console.Write($@"Safe {ListFolderDelete.Count} Folder ... "); foreach (var folder in ListFolderDelete) { var path = folder.FolderPath; foreach (var variable in variableList) { path = path.Replace("@(" + variable.Name + ")", variable.Value); } path = Environment.ExpandEnvironmentVariables(path); var fileInfo = new DirectoryInfo(path); var maxLoop = 2; for (int i = 0; i < maxLoop; i++) { try { Thread.Sleep(10000); fileMaker.DeleteFolder(fileInfo, folder.CheckFile); break; } catch (Exception ex) { if (i == (maxLoop - 1)) { throw; } Console.WriteLine(ex.Message); Console.WriteLine("retrying..."); } } } Console.WriteLine("Done"); }