/// <summary> /// Runs the tool using a custom tool path and the specified settings. /// </summary> /// <param name="settings">The settings.</param> /// <param name="arguments">The arguments.</param> /// <param name="toolPath">The tool path to use.</param> protected void Run(T settings, ToolArgumentBuilder arguments, FilePath toolPath) { if (arguments == null) { throw new ArgumentNullException("arguments"); } // Get the tool name. var toolName = GetToolName(); // Get the tool path. toolPath = GetToolPath(settings, toolPath); if (toolPath == null || !_fileSystem.Exist(toolPath)) { const string message = "{0}: Could not locate executable."; throw new CakeException(string.Format(CultureInfo.InvariantCulture, message, toolName)); } // Get the working directory. var workingDirectory = GetWorkingDirectory(settings); if (workingDirectory == null) { const string message = "{0}: Could not resolve working directory."; throw new CakeException(string.Format(CultureInfo.InvariantCulture, message, toolName)); } // Create the process start info. var info = new ProcessStartInfo(toolPath.FullPath) { WorkingDirectory = workingDirectory.MakeAbsolute(_environment).FullPath, Arguments = arguments.Render(), UseShellExecute = false }; // Run the process. var process = _processRunner.Start(info); if (process == null) { const string message = "{0}: Process was not started."; throw new CakeException(string.Format(CultureInfo.InvariantCulture, message, toolName)); } // Wait for the process to exit. process.WaitForExit(); // Did an error occur? if (process.GetExitCode() != 0) { const string message = "{0}: Process returned an error."; throw new CakeException(string.Format(CultureInfo.InvariantCulture, message, toolName)); } }
/// <summary> /// Runs the tool using the specified settings. /// </summary> /// <param name="settings">The settings.</param> /// <param name="arguments">The arguments.</param> protected void Run(T settings, ToolArgumentBuilder arguments) { Run(settings, arguments, null); }