2 using System.Collections.Generic;
 
    3 using System.ComponentModel;
 
    4 using System.Diagnostics;
 
    6 using System.Threading.Tasks;
 
    7 using SiliconStudio.Core.Diagnostics;
 
    9 namespace SiliconStudio.BuildEngine
 
   11     [Description(
"Run external process")]
 
   15         public override string Title { 
get { 
string title = 
"External Process "; 
try { title += Path.GetFileName(ProcessPath) ?? 
"[Process]"; } 
catch { title += 
"[INVALID PATH]"; } 
return title; } }
 
   17         public string ProcessPath { 
get; set; }
 
   18         public string Arguments { 
get; set; }
 
   28         private Process process;
 
   34             logger = commandContext.Logger;
 
   35             if (!
File.Exists(ProcessPath))
 
   37                 logger.Error(
"Unable to find binary file " + ProcessPath);
 
   38                 return Task.FromResult(ResultStatus.Failed);
 
   41             var startInfo = 
new ProcessStartInfo
 
   43                 FileName = ProcessPath,
 
   44                 Arguments = Arguments,
 
   45                 WorkingDirectory = 
".",
 
   46                 UseShellExecute = 
false,
 
   47                 RedirectStandardOutput = 
true 
   49             process = Process.Start(startInfo);
 
   50             process.OutputDataReceived += OnOutputDataReceived;
 
   51             process.BeginOutputReadLine();
 
   52             process.WaitForExit();
 
   54             ExitCode = process.ExitCode;
 
   56             return Task.FromResult(CancellationToken.IsCancellationRequested ? ResultStatus.Cancelled : (ExitCode == 0 ? ResultStatus.Successful : ResultStatus.Failed));
 
   59         private void OnOutputDataReceived(
object sender, DataReceivedEventArgs e)
 
   71             return "External process " + (ProcessPath ?? 
"[Process]") + (Arguments != null ? 
" " + Arguments : 
"");
 
override string ToString()
 
Base implementation for ILogger. 
 
int ExitCode
An optional return code from the command 
 
override Task< ResultStatus > DoCommandOverride(ICommandContext commandContext)
The method to override containing the actual command code. It is called by the DoCommand function ...
 
override void Cancel()
Callback called by Builder.CancelBuild. It can be useful for commands in a blocking call that can be ...