private void XcodeBuild() { string workPath = Path.Combine(Module.ModuleConfig.WorkPath, EBPUtility.GetTagStr(Module.ModuleStateConfig.Json.CurrentTag)); message = errorMessage = ""; Module.DisplayProgressBar("Start Xcode Build...", 0, true); using (var xcodeBuildLogWriter = new StreamWriter(Path.Combine(CommonModule.CommonConfig.CurrentLogFolderPath, "XcodeBuild.log")) { AutoFlush = true }) { Process p = SVNUpdate.Runner.ExcuteCommand("/bin/bash", EBPUtility.Quote(Path.Combine(Module.ModuleConfig.ModuleRootPath, "Shells/XcodeBuild.sh")) + " " + EBPUtility.Quote(workPath) + " " + EBPUtility.Quote("Project/Unity-iPhone.xcodeproj"), (object sender, DataReceivedEventArgs e) => { message = e.Data; xcodeBuildLogWriter.WriteLine(message); }, OnErrorReceived, null); int progress = 0; while (!p.HasExited) { Module.DisplayProgressBar("Xcode Building...", message, (float)(progress++ % 1000) / 1000); System.Threading.Thread.Sleep(100); } if (p.ExitCode != 0) { throw new EBPException("XcodeBuild Shell Error: " + errorMessage); } } Module.DisplayProgressBar("Xcode Build", "Finish!", 1, true); }
void GetRepositoryInfoAndLocalVersion() { const string urlName = "URL: "; const string versionName = "Revision: "; foreach (var line in SVNInfo.Split('\n')) { //获取仓库信息 if (line.Length > urlName.Length && line.Substring(0, urlName.Length) == urlName) { string repositoryURL = line.Substring(urlName.Length); try { ExcuteCommand("svn", "info " + EBPUtility.Quote(repositoryURL), OnRepositoryInfoReceived, OnInfoErrorReceived, OnRepositoryInfoExited); } catch (Exception err) { InfoErrorMessage = err.Message; InfoExitedAction(false); } } //获取本地版本 else if (line.Length > versionName.Length && line.Substring(0, versionName.Length) == versionName) { LocalVersion = line.Substring(versionName.Length); } } }
protected override void RunProcess() { int progress = 0; message = ""; errorMessage = ""; Module.DisplayProgressBar("SVN Update Starting...", 0, true); Process p; p = ExcuteCommand("/bin/bash", EBPUtility.Quote(Path.Combine(Module.ModuleConfig.ModuleRootPath, "SVNUpdate.sh")) + " " + EBPUtility.Quote(Path.Combine(CommonModule.CommonConfig.CurrentLogFolderPath, "SVNUpdate.log")), OnReceived, OnErrorReceived, OnExited); while (!p.HasExited) { Module.DisplayProgressBar("SVN Updating...", message, (float)(progress++ % 1000) / 1000); System.Threading.Thread.Sleep(50); } if (p.ExitCode != 0) { throw new EBPException("SVN Update Error: " + errorMessage); } Module.DisplayProgressBar("SVN", "Finish!", 1, true); }
void OnRepositoryInfoExited(object sender, EventArgs e) { Process process = (Process)sender; Available = process.ExitCode == 0; if (Available) { //设置版本状态 if (LocalVersion != "" && RepositoryVersion != "") { VersionState = RepositoryVersion == LocalVersion ? VersionStateEnum.Latest : VersionStateEnum.Obsolete; } //检查本地修改 if (Module.ModuleConfig.Json.EnableCheckDiff) { try { ExcuteCommand("/bin/bash", EBPUtility.Quote(Path.Combine(Module.ModuleConfig.ModuleRootPath, "SVNDiff.sh")), OnDiffReceived, OnDiffErrorReceived, OnDiffExited); } catch (Exception err) { InfoErrorMessage = err.Message; DiffExitedAction(false); } } } else { IsPartOfPipeline = false; } if (InfoExitedAction != null) { InfoExitedAction(Available); } }
public void RevertAllCopiedFiles(string[] copiedFilesLogText, string revertLogPath) { //读入所有已拷贝的文件列表 var revertFolderList = new List <string>(); var revertFilesList = new List <string>(); bool revertThis = false; foreach (var line in copiedFilesLogText) { if (line[0] == 'R' && line[1] == ' ') { revertFolderList.Add(line.Substring(2).Trim()); revertThis = true; } else if (line[0] == 'D' && line[1] == ' ') { revertThis = false; } else if (line[0] == ' ' && line[1] == ' ' && revertThis) { revertFilesList.Add(line.Substring(2).Trim()); } } //单独的日志文件 errorMessage = ""; float progress = 0; //删除所有已拷贝并标记为R(revert)的文件(不存在的文件不记录日志) using (var logWriter = new StreamWriter(revertLogPath, true)) { Module.DisplayProgressBar("Start Delete Copied Files", 0, true); logWriter.WriteLine("Start Delete Files"); logWriter.Flush(); foreach (string file in revertFilesList) { if (File.Exists(file)) { Module.DisplayProgressBar("Delete Copied Files", file, progress++ % 1000 / 1000); File.Delete(file); logWriter.WriteLine("Deleted: " + file); logWriter.Flush(); } } logWriter.WriteLine("End Delete Files"); logWriter.Flush(); Module.DisplayProgressBar("End Delete Copied Files", 0, true); } //还原目录 progress = 0; Module.DisplayProgressBar("Start Revert All Copied Files", 0, true); foreach (var folderPath in revertFolderList) { string title = "Revert Copied Files in " + EBPUtility.Quote(Path.GetFileName(folderPath)); Module.DisplayProgressBar(title, "Start Revert " + EBPUtility.Quote(folderPath), 0, true); Process p = SVNUpdate.Runner.ExcuteCommand("/bin/bash", EBPUtility.Quote(Path.Combine(Module.ModuleConfig.ModuleRootPath, "Shells/SVNRevert.sh")) + " " + EBPUtility.Quote(folderPath) + " " + EBPUtility.Quote(revertLogPath), OnReceived, OnErrorReceived, null); while (!p.HasExited) { Module.DisplayProgressBar(title, message, progress++ % 1000 / 1000); System.Threading.Thread.Sleep(50); } if (p.ExitCode != 0) { throw new EBPException("还原目录(" + folderPath + ")时发生错误:" + errorMessage); } Module.DisplayProgressBar(title, "Finish!", 1, true); } Module.DisplayProgressBar("End Revert All Copied Files", 1, true); EBPUtility.RefreshAssets(); }