[xbuild] Don't show the deprecation notice for minimal or quiet logging
authorAnkit Jain <ankit.jain@xamarin.com>
Thu, 16 Feb 2017 21:56:28 +0000 (16:56 -0500)
committerAnkit Jain <ankit.jain@xamarin.com>
Thu, 16 Feb 2017 21:57:07 +0000 (16:57 -0500)
.. levels. This is useful for scripts that might depend on minimal/quiet
levels, to parse output of a specific target execution, eg.
Xamarin.Android .

mcs/tools/xbuild/Main.cs

index e34909337b00f2c6a4448f1d29fc5d8084d52af0..e81574d27879487030f093450c810ded1a3fb12b 100644 (file)
@@ -55,16 +55,8 @@ namespace Mono.XBuild.CommandLine {
                // this does nothing but adds strong reference to Microsoft.Build.Tasks*.dll that we need to load consistently.
                Microsoft.Build.Tasks.Copy dummy;
 #pragma warning restore
-
                public static void Main (string[] args)
                {
-                       Console.ForegroundColor = ConsoleColor.DarkRed;
-                       Console.WriteLine ();
-                       Console.WriteLine (">>>> xbuild tool is deprecated and will be removed in future updates, use msbuild instead <<<<");
-                       Console.WriteLine ();
-                       Console.ResetColor ();
-
-
                        MainClass mc = new MainClass ();
                        mc.args = args;
                        mc.Execute ();
@@ -83,7 +75,14 @@ namespace Mono.XBuild.CommandLine {
                        bool show_stacktrace = false;
                        
                        try {
-                               parameters.ParseArguments (args);
+                               try {
+                                       parameters.ParseArguments (args);
+                               } catch {
+                                       ShowDeprecationNotice ();
+                                       throw;
+                               }
+
+                               ShowDeprecationNotice ();
                                show_stacktrace = (parameters.LoggerVerbosity == LoggerVerbosity.Detailed ||
                                        parameters.LoggerVerbosity == LoggerVerbosity.Diagnostic);
                                
@@ -173,6 +172,17 @@ namespace Mono.XBuild.CommandLine {
                        }
 
                }
+
+               void ShowDeprecationNotice ()
+               {
+                       if (parameters.LoggerVerbosity != LoggerVerbosity.Minimal && parameters.LoggerVerbosity != LoggerVerbosity.Quiet) {
+                               Console.ForegroundColor = ConsoleColor.DarkRed;
+                               Console.WriteLine ();
+                               Console.WriteLine (">>>> xbuild tool is deprecated and will be removed in future updates, use msbuild instead <<<<");
+                               Console.WriteLine ();
+                               Console.ResetColor ();
+                       }
+               }
        }
 
        // code from mcs/report.cs