[xbuild] ToolTask - make error column check a little non-specific.
[mono.git] / mcs / class / Microsoft.Build.Utilities / Microsoft.Build.Utilities / ToolTask.cs
index c2ccff4c5c6763be8a0dea8a8a06e0043228bbda..4094c122e3b9e9afc86574ece4e1ea98afbd9cb9 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 ();
@@ -264,7 +258,7 @@ namespace Microsoft.Build.Utilities
                        string col = match.Result ("${column}");
                        int columnNumber = 0;
                        if (!string.IsNullOrEmpty (col))
-                               columnNumber = col == "255+" ? -1 : Int32.Parse (col);
+                               columnNumber = col.IndexOf ("+") >= 0 ? -1 : Int32.Parse (col);
 
                        string category = match.Result ("${level}");
                        string code = match.Result ("${number}");
@@ -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)