Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

i-e-b/RunProcess

Open more actions menu

Repository files navigation

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

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

Or,

using (var proc = new ProcessHost(msBuildExe, projectDir)) {
    proc.Start(projectFile + " /t:Publish");
        
    int resultCode;
    if (!proc.WaitForExit(TimeSpan.FromMinutes(1), out resultCode))
    {
        proc.Kill();
        throw new Exception("Publish killed -- took too long");
    }

    File.AppendAllText(logFile, proc.StdOut.ReadAllText(Encoding.UTF8));
    File.AppendAllText(logFile, proc.StdErr.ReadAllText(Encoding.UTF8));

    if (resultCode != 0)
    {
        throw new Exception("Publish failure: see \"" + logFile + "\" for details");
    }
}

About

Replacement for System.Diagnostics.Process

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.