[mono/tests] Fix out of tree build.
[mono-project.git] / mcs / tools / xbuild / ErrorUtilities.cs
blobc91f97b40a6332a7309b0220c513f614c1bc2fdc
1 //
2 // ErrorUtilities.cs: Functions that print out errors, warnings, help etc.
3 //
4 // Author:
5 // Marek Sieradzki (marek.sieradzki@gmail.com)
6 //
7 // (C) 2006 Marek Sieradzki
8 //
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 using System;
31 namespace Mono.XBuild.CommandLine {
32 public static class ErrorUtilities {
34 static string[] version = {
35 String.Format ("XBuild Engine Version {0}", XBuildConsts.Version),
36 String.Format ("Mono, Version {0}", Consts.MonoVersion),
37 "Copyright (C) 2005-2013 Various Mono authors",
41 static public void ReportError (int errorNum, string msg)
43 Console.WriteLine (String.Format ("MSBUILD: error MSBUILD{0:0000}: {1}", errorNum, msg));
44 Environment.Exit (1);
47 static public void ReportWarning (int errorNum, string msg)
49 Console.WriteLine (String.Format ("MSBUILD: warning MSBUILD{0:0000}: {1}", errorNum, msg));
52 static public void ReportInvalidArgument (string option, string value)
54 ReportError (1012, String.Format ("'{0}' is not a valid setting for option '{1}'", value, option));
57 static public void ReportMissingArgument (string option)
59 ReportError (1003, String.Format ("Compiler option '{0}' must be followed by an argument", option));
62 static public void ReportNotImplemented (string option)
64 ReportError (0, String.Format ("Compiler option '{0}' is not implemented", option));
67 static public void ReportMissingFileSpec (string option)
69 ReportError (1008, String.Format ("Missing file specification for '{0}' command-line option", option));
72 static public void ReportMissingText (string option)
74 ReportError (1010, String.Format ("Missing ':<text>' for '{0}' option", option));
77 static public void ShowUsage ()
79 Display (version);
80 Console.WriteLine ("xbuild [options] [project-file]");
81 Console.WriteLine (
82 " /version Show the xbuild version\n" +
83 " /noconsolelogger Disable the default console logger\n" +
84 " /target:T1[,TN] List of targets to build\n" +
85 " /property:Name=Value\n" +
86 " Set or override project properties\n" +
87 " /logger:<logger> Custom logger to log events\n" +
88 " /verbosity:<level> Logger verbosity level : quiet, minimal, normal, detailed, diagnostic\n" +
89 " /validate Validate the project file against the schema\n" +
90 " /validate:<schema> Validate the project file against the specified schema\n" +
91 " /consoleloggerparameters:<params>\n" +
92 " /clp:<params>\n" +
93 " Parameters for the console logger\n" +
94 " /fileloggerparameters[n]:<params>\n" +
95 " /flp[n]:<params>\n" +
96 " Parameters for the file logger, eg. LogFile=foo.log\n" +
97 " /nologo Don't show the initial banner\n" +
98 " /help Show this help\n"
100 Environment.Exit (0);
103 static public void ShowVersion (bool exit)
105 Display (version);
106 if (exit)
107 Environment.Exit (0);
110 static private void Display (string[] array)
112 foreach (string s in array)
113 Console.WriteLine (s);