ProcessUtils
Async Process Helper
Assembly: ServiceStack.Common.dll
View Source
Declaration
public static class ProcessUtils
Methods
ConvertToCmdExec(ProcessStartInfo)
.NET Core / Win throws Win32Exception (193): The specified executable is not a valid application for this OS platform. This method converts it to a cmd.exe /c execute to workaround this
View Source
Declaration
public static ProcessStartInfo ConvertToCmdExec(this ProcessStartInfo startInfo)
Returns
System.Diagnostics.ProcessStartInfo
Parameters
| Type | Name | 
|---|---|
| System.Diagnostics.ProcessStartInfo | startInfo | 
FindExePath(String)
Returns path of executable if exists within PATH
View Source
Declaration
public static string FindExePath(string exeName)
Returns
System.String
Parameters
| Type | Name | 
|---|---|
| System.String | exeName | 
RunShell(String, String)
Run the command with the OS's command runner
View Source
Declaration
public static string RunShell(string arguments, string workingDir = null)
Returns
System.String
Parameters
| Type | Name | 
|---|---|
| System.String | arguments | 
| System.String | workingDir | 
Run(String, String, String)
Run the process and return the Standard Output, any Standard Error output will throw an Exception
View Source
Declaration
public static string Run(string fileName, string arguments = null, string workingDir = null)
Returns
System.String
Parameters
| Type | Name | 
|---|---|
| System.String | fileName | 
| System.String | arguments | 
| System.String | workingDir | 
CreateProcess(String, String, String)
View Source
Declaration
public static Process CreateProcess(string fileName, string arguments, string workingDir)
Returns
System.Diagnostics.Process
Parameters
| Type | Name | 
|---|---|
| System.String | fileName | 
| System.String | arguments | 
| System.String | workingDir | 
RunShellAsync(String, String, Nullable<Int32>, Action<String>, Action<String>)
Run the command with the OS's command runner
View Source
Declaration
public static async Task RunShellAsync(string arguments, string workingDir = null, int? timeoutMs = null, Action<string> onOut = null, Action<string> onError = null)
Returns
System.Threading.Tasks.Task
Parameters
| Type | Name | 
|---|---|
| System.String | arguments | 
| System.String | workingDir | 
| System.Nullable<System.Int32> | timeoutMs | 
| System.Action<System.String> | onOut | 
| System.Action<System.String> | onError | 
RunAsync(ProcessStartInfo, Nullable<Int32>, Action<String>, Action<String>)
Run a Process asynchronously, returning entire captured process output, whilst streaming stdOut, stdErr callbacks
View Source
Declaration
public static async Task<ProcessResult> RunAsync(ProcessStartInfo startInfo, int? timeoutMs = null, Action<string> onOut = null, Action<string> onError = null)
Returns
System.Threading.Tasks.Task<ServiceStack.ProcessResult>
Parameters
| Type | Name | 
|---|---|
| System.Diagnostics.ProcessStartInfo | startInfo | 
| System.Nullable<System.Int32> | timeoutMs | 
| System.Action<System.String> | onOut | 
| System.Action<System.String> | onError | 
CreateErrorResult(Exception)
View Source
Declaration
public static ProcessResult CreateErrorResult(Exception e)
Returns
Parameters
| Type | Name | 
|---|---|
| System.Exception | e |