WaitForExit() public method

public WaitForExit ( int milliseconds ) : bool
milliseconds int
return bool
 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;
 }
Exemplo n.º 2
0
 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();
     }
 }
Exemplo n.º 3
0
 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;
 }
Exemplo n.º 4
0
 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;
 }
Exemplo n.º 7
0
 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;
 }
Exemplo n.º 8
0
 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();
         }
     }
 }
Exemplo n.º 10
0
 public static int RunAndWait(string fileName, string arguments, out string result, [Optional, DefaultParameterValue(null)] IDictionary<string, string> environmentVariables)
 {
     ProcessStartInfo si = new ProcessStartInfo(fileName, arguments) {
         CreateNoWindow = true,
         RedirectStandardOutput = true,
         UseShellExecute = false
     };
     if (environmentVariables != null)
     {
         foreach (KeyValuePair<string, string> pair in environmentVariables)
         {
             si.EnvironmentVariables.Add(pair.Key, pair.Value);
         }
     }
     using (Program program = new Program(si))
     {
         program.Start();
         program.WaitForExit();
         result = program.GetStandardOutputAsString();
         return program.ExitCode;
     }
 }