From 35044c74a25b2c3c983ceca94f5163fa309a495c Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Mon, 28 Feb 2011 00:41:07 +0530 Subject: [PATCH] [xbuild] ToolTask - add missing api * Microsoft.Build.Utilities/Microsoft.Build.Utilities/ToolTask.cs (GetProcessStartInfo): Add missing api. This allows more control over the execution of the tool. --- .../Microsoft.Build.Utilities/ToolTask.cs | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities/ToolTask.cs b/mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities/ToolTask.cs index c2ccff4c5c6..4e88792a649 100644 --- a/mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities/ToolTask.cs +++ b/mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities/ToolTask.cs @@ -114,22 +114,16 @@ namespace Microsoft.Build.Utilities toolOutput = new StringBuilder (); try { - string arguments = commandLineCommands; + string responseFileSwitch = String.Empty; if (!String.IsNullOrEmpty (responseFileCommands)) { responseFileName = Path.GetTempFileName (); File.WriteAllText (responseFileName, responseFileCommands); - arguments = arguments + " " + GetResponseFileSwitch (responseFileName); + responseFileSwitch = GetResponseFileSwitch (responseFileName); } + var pinfo = GetProcessStartInfo (pathToTool, commandLineCommands, responseFileSwitch); LogToolCommand (String.Format ("Tool {0} execution started with arguments: {1} {2}", - pathToTool, commandLineCommands, responseFileCommands)); - - ProcessStartInfo pinfo = new ProcessStartInfo (pathToTool, arguments); - pinfo.WorkingDirectory = GetWorkingDirectory () ?? Environment.CurrentDirectory; - - pinfo.UseShellExecute = false; - pinfo.RedirectStandardOutput = true; - pinfo.RedirectStandardError = true; + pinfo.FileName, commandLineCommands, responseFileCommands)); var pendingLineFragmentOutput = new StringBuilder (); var pendingLineFragmentError = new StringBuilder (); @@ -298,6 +292,18 @@ namespace Microsoft.Build.Utilities return String.Format ("@{0}", responseFilePath); } + protected virtual ProcessStartInfo GetProcessStartInfo (string pathToTool, string commandLineCommands, string responseFileSwitch) + { + var pinfo = new ProcessStartInfo (pathToTool, String.Format ("{0} {1}", commandLineCommands, responseFileSwitch)); + + pinfo.WorkingDirectory = GetWorkingDirectory () ?? Environment.CurrentDirectory; + pinfo.UseShellExecute = false; + pinfo.RedirectStandardOutput = true; + pinfo.RedirectStandardError = true; + + return pinfo; + } + protected virtual bool HandleTaskExecutionErrors () { if (!Log.HasLoggedErrors && exitCode != 0) -- 2.25.1