public static string Run(ProcessStartInfo psi, WaitingForProcessToExit waitingForProcessToExit, string errorMsg) { using (Program program = new Program(psi)) { program.Start(); do { if (waitingForProcessToExit != null) { waitingForProcessToExit(program); } } while (!program.WaitForExit(100)); if (program.ExitCode != 0) { throw new CommandInvokationFailure(errorMsg, program); } StringBuilder builder = new StringBuilder(""); foreach (string str in program.GetStandardOutput()) { builder.Append(str + Environment.NewLine); } foreach (string str2 in program.GetErrorOutput()) { builder.Append(str2 + Environment.NewLine); } return builder.ToString(); } }
public bool EnsureProjectLockFile(string projectFile) { string directoryName = Path.GetDirectoryName(this.ProjectLockFile); string str1 = FileUtil.NiceWinPath(Path.Combine(directoryName, Path.GetFileName(projectFile))); Console.WriteLine("Restoring NuGet packages from \"{0}\".", (object) Path.GetFullPath(str1)); if (File.Exists(this.ProjectLockFile)) { Console.WriteLine("Done. Reusing existing \"{0}\" file.", (object) Path.GetFullPath(this.ProjectLockFile)); return true; } if (!string.IsNullOrEmpty(directoryName)) Directory.CreateDirectory(directoryName); File.Copy(projectFile, str1, true); string str2 = FileUtil.NiceWinPath(Path.Combine(BuildPipeline.GetBuildToolsDirectory(BuildTarget.WSAPlayer), "nuget.exe")); Program program = new Program(new ProcessStartInfo() { Arguments = string.Format("restore \"{0}\" -NonInteractive -Source https://api.nuget.org/v3/index.json", (object) str1), CreateNoWindow = true, FileName = str2 }); using (program) { program.Start(); for (int index = 0; index < 15; ++index) { if (!program.WaitForExit(60000)) Console.WriteLine("Still restoring NuGet packages."); } if (!program.HasExited) throw new Exception(string.Format("Failed to restore NuGet packages:{0}Time out.", (object) Environment.NewLine)); if (program.ExitCode != 0) throw new Exception(string.Format("Failed to restore NuGet packages:{0}{1}", (object) Environment.NewLine, (object) program.GetAllOutput())); } Console.WriteLine("Done."); return false; }
internal static bool StartProgramChecked(Program p) { bool flag; if (EmccArguments.debugEnvironmentAndInvocations) { Debug.Log(p.GetProcessStartInfo().Arguments); } using (p) { p.LogProcessStartInfo(); try { p.Start(); } catch { throw new Exception("Could not start "); } p.WaitForExit(); if (p.ExitCode == 0) { flag = true; } else { Debug.LogError("Failed running " + p.GetProcessStartInfo().FileName + " " + p.GetProcessStartInfo().Arguments + "\n\n" + p.GetAllOutput()); throw new Exception("Failed building WebGL Player."); } } return flag; }
private static string ExecuteSystemProcess(string command, string args, string workingdir, bool displayProgress, string progressTitle, string progressInfo) { if (displayProgress) { EditorUtility.DisplayCancelableProgressBar(progressTitle, progressInfo, 0.25f); } ProcessStartInfo si = new ProcessStartInfo { FileName = command, Arguments = args, WorkingDirectory = workingdir, CreateNoWindow = true, UseShellExecute = true }; Program program = new Program(si); program.Start(); while (!program.WaitForExit(100)) { } string str = StringConcat(program.GetStandardOutput()) + StringConcat(program.GetErrorOutput()); program.Dispose(); UnityEngine.Debug.Log(command + " " + args + "\n" + str); if (displayProgress) { EditorUtility.ClearProgressBar(); } return str; }
private void RunProgram(ProcessStartInfo startInfo) { using (var program = new UnityEditor.Utils.Program(startInfo)) { program.Start(); while (!program.WaitForExit(100)) { } var output = string.Empty; var standardOutput = program.GetStandardOutput(); if (standardOutput.Length > 0) { output = standardOutput.Aggregate((buf, s) => buf + Environment.NewLine + s); } var errorOutput = program.GetErrorOutput(); if (errorOutput.Length > 0) { output += errorOutput.Aggregate((buf, s) => buf + Environment.NewLine + s); } if (program.ExitCode != 0) { UnityEngine.Debug.LogError("Failed running " + startInfo.FileName + " " + startInfo.Arguments + "\n\n" + output); throw new Exception("IL2CPP compile failed."); } } }
internal static string ExecuteSystemProcess(string command, string args, string workingdir) { ProcessStartInfo si = new ProcessStartInfo { FileName = command, Arguments = args, WorkingDirectory = workingdir, CreateNoWindow = true }; Program program = new Program(si); program.Start(); while (!program.WaitForExit(100)) { } string standardOutputAsString = program.GetStandardOutputAsString(); program.Dispose(); return standardOutputAsString; }
public bool EnsureProjectLockFile(string projectFile) { string path = FileUtil.NiceWinPath(Path.Combine(Path.GetDirectoryName(this.ProjectLockFile), Path.GetFileName(projectFile))); Console.WriteLine("Restoring NuGet packages from \"{0}\".", Path.GetFullPath(path)); if (File.Exists(this.ProjectLockFile)) { Console.WriteLine("Done. Reusing existing \"{0}\" file.", Path.GetFullPath(this.ProjectLockFile)); return true; } File.Copy(projectFile, path, true); string str3 = FileUtil.NiceWinPath(Path.Combine(BuildPipeline.GetBuildToolsDirectory(BuildTarget.WSAPlayer), "nuget.exe")); ProcessStartInfo si = new ProcessStartInfo { Arguments = string.Format("restore \"{0}\" -NonInteractive -Source https://api.nuget.org/v3/index.json", path), CreateNoWindow = true, FileName = str3 }; Program program = new Program(si); using (program) { program.Start(); for (int i = 0; i < 15; i++) { if (!program.WaitForExit(0xea60)) { Console.WriteLine("Still restoring NuGet packages."); } } if (!program.HasExited) { throw new Exception(string.Format("Failed to restore NuGet packages:{0}Time out.", Environment.NewLine)); } if (program.ExitCode != 0) { throw new Exception(string.Format("Failed to restore NuGet packages:{0}{1}", Environment.NewLine, program.GetAllOutput())); } } Console.WriteLine("Done."); return false; }
private Program StartCompilerImpl(List<string> arguments, string argsPrefix, bool msBuildCompiler) { foreach (string reference in this._island._references) arguments.Add("/reference:" + ScriptCompilerBase.PrepareFileName(reference)); foreach (string str in ((IEnumerable<string>) this._island._defines).Distinct<string>()) arguments.Add("/define:" + str); foreach (string file in this._island._files) arguments.Add(ScriptCompilerBase.PrepareFileName(file).Replace('/', '\\')); string path = !msBuildCompiler ? Path.Combine(MicrosoftCSharpCompiler.WindowsDirectory, "Microsoft.NET\\Framework\\v4.0.30319\\Csc.exe") : Path.Combine(MicrosoftCSharpCompiler.ProgramFilesDirectory, "MSBuild\\14.0\\Bin\\csc.exe"); if (!File.Exists(path)) throw new Exception("'" + path + "' not found, either .NET 4.5 is not installed or your OS is not Windows 8/8.1."); this.AddCustomResponseFileIfPresent(arguments, "csc.rsp"); string responseFile = CommandLineFormatter.GenerateResponseFile((IEnumerable<string>) arguments); Program program = new Program(new ProcessStartInfo() { Arguments = argsPrefix + "@" + responseFile, FileName = path, CreateNoWindow = true }); program.Start(); return program; }
private string RunCommand(string command, string arguments) { try { ProcessStartInfo si = new ProcessStartInfo(command) { Arguments = arguments }; Program program = new Program(si); program.Start(); program.WaitForExit(); if (program.ExitCode < 0) { return null; } StringBuilder builder = new StringBuilder(); foreach (string str2 in program.GetStandardOutput()) { builder.AppendLine(str2); } return builder.ToString().TrimEnd(Environment.NewLine.ToCharArray()); } catch (Win32Exception) { return null; } }
public void PostProcess(BuildPostProcessArgs args) { base.m_PostProcessArgs = args; AssemblyReferenceChecker checker = new AssemblyReferenceChecker(); checker.CollectReferences(args.stagingAreaDataManaged, false, 0f, true); bool flag = !string.IsNullOrEmpty(checker.WhoReferencesClass("UnityEngine.SocialPlatforms.GameCenter.GameCenterPlatform", true)); this.SaveEditorOnlyPlayerSettingsToPlist(); base.PostProcess(); if (flag) { if (Application.platform != RuntimePlatform.OSXEditor) { UnityEngine.Debug.LogWarning("OS X Standalone players with GameCenter support need to be built on an OS X machine in order to pass Mac App Store validation."); } else { Console.WriteLine("Adding GameKit linkage to OS X binary."); ProcessStartInfo info2 = new ProcessStartInfo { FileName = Path.Combine(BuildPipeline.GetPlaybackEngineDirectory(args.target, args.options), "optool") }; string[] textArray1 = new string[] { "install -c weak -p /System/Library/Frameworks/GameKit.framework/Versions/A/GameKit -t \"", this.m_PostProcessArgs.installPath, "/Contents/MacOS/", this.InstallNameWithoutExtension, "\"" }; info2.Arguments = string.Concat(textArray1); info2.CreateNoWindow = true; ProcessStartInfo si = info2; Program program = new Program(si); program.Start(); while (!program.WaitForExit(100)) { } if (program.ExitCode != 0) { UnityEngine.Debug.LogError("Running optool to link GameKit failed\n" + si.FileName + " " + si.Arguments + "\n" + program.GetAllOutput()); } program.Dispose(); } } }
private Program StartCompilerImpl(List<string> arguments, string argsPrefix) { string[] references = this._island._references; for (int i = 0; i < references.Length; i++) { string fileName = references[i]; arguments.Add("/reference:" + ScriptCompilerBase.PrepareFileName(fileName)); } foreach (string current in this._island._defines.Distinct<string>()) { arguments.Add("/define:" + current); } string[] files = this._island._files; for (int j = 0; j < files.Length; j++) { string fileName2 = files[j]; arguments.Add(ScriptCompilerBase.PrepareFileName(fileName2).Replace('/', '\\')); } string text = Path.Combine(MicrosoftCSharpCompiler.WindowsDirectory, "Microsoft.NET\\Framework\\v4.0.30319\\Csc.exe"); if (!File.Exists(text)) { throw new Exception("'" + text + "' not found, either .NET 4.5 is not installed or your OS is not Windows 8/8.1."); } base.AddCustomResponseFileIfPresent(arguments, "csc.rsp"); string str = CommandLineFormatter.GenerateResponseFile(arguments); ProcessStartInfo si = new ProcessStartInfo { Arguments = argsPrefix + "@" + str, FileName = text, CreateNoWindow = true }; Program program = new Program(si); program.Start(); return program; }