项目作者: i-e-b

项目描述 :
Replacement for System.Diagnostics.Process
高级语言: C#
项目地址: git://github.com/i-e-b/RunProcess.git
创建时间: 2013-02-13T15:33:49Z
项目社区:https://github.com/i-e-b/RunProcess

开源协议:BSD 3-Clause "New" or "Revised" License

下载


RunProcess

A process host for Windows (Vista and later) that is more reliable and flexible than System.Diagnostics.Process

Allows run-time reading from std error and output, and writing to std input.

The .Net Standard build has a few less features, but will fall-back to System.Diagnostics.Process on non-Windows systems.

Usage

Like this

  1. using (var proc = new ProcessHost("my.exe", @"C:\temp\")) {
  2. proc.Start();
  3. }

Or,

  1. using (var proc = new ProcessHost(msBuildExe, projectDir)) {
  2. proc.Start(projectFile + " /t:Publish");
  3. int resultCode;
  4. if (!proc.WaitForExit(TimeSpan.FromMinutes(1), out resultCode))
  5. {
  6. proc.Kill();
  7. throw new Exception("Publish killed -- took too long");
  8. }
  9. File.AppendAllText(logFile, proc.StdOut.ReadAllText(Encoding.UTF8));
  10. File.AppendAllText(logFile, proc.StdErr.ReadAllText(Encoding.UTF8));
  11. if (resultCode != 0)
  12. {
  13. throw new Exception("Publish failure: see \"" + logFile + "\" for details");
  14. }
  15. }