[xbuild] ToolTask - add missing api
authorAnkit Jain <radical@corewars.org>
Sun, 27 Feb 2011 19:11:07 +0000 (00:41 +0530)
committerAnkit Jain <radical@corewars.org>
Sun, 27 Feb 2011 21:40:15 +0000 (03:10 +0530)
* Microsoft.Build.Utilities/Microsoft.Build.Utilities/ToolTask.cs
(GetProcessStartInfo): Add missing api. This allows more control
over the execution of the tool.

mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities/ToolTask.cs

index c2ccff4c5c6763be8a0dea8a8a06e0043228bbda..4e88792a64963aa182faccdd1dc9602a1af1462a 100644 (file)
@@ -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)