2 // ErrorUtilities.cs: Functions that print out errors, warnings, help etc.
5 // Marek Sieradzki (marek.sieradzki@gmail.com)
7 // (C) 2006 Marek Sieradzki
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.
32 namespace Mono.XBuild.CommandLine {
33 public static class ErrorUtilities {
35 static string[] usage = {
37 "Syntax: xbuild.exe [options] [project file]",
39 "Description: Builds the specified targets in the project file. If",
40 " a project file is not specified, MSBuild searches the",
41 " current working directory for a file that has a file",
42 " extension that ends in \"proj\" and uses that file.",
46 " /help Display this usage message. (Short form: /? or /h)",
48 " /nologo Do not display the startup banner and copyright message.",
50 " /version Display version information only. (Short form: /ver)",
52 " @<file> Insert command-line settings from a text file. To specify",
53 " multiple response files, specify each response file",
56 " /noautoresponse Do not auto-include the MSBuild.rsp file. (Short form:",
59 " /target:<targets> Build these targets in this project. Use a semicolon or a",
60 " comma to separate multiple targets, or specify each",
61 " target separately. (Short form: /t)",
63 " /target:Resources;Compile",
65 " /property:<n>=<v> Set or override these project-level properties. <n> is",
66 " the property name, and <v> is the property value. Use a",
67 " semicolon or a comma to separate multiple properties, or",
68 " specify each property separately. (Short form: /p)",
70 @" /property:WarningLevel=2;OutDir=bin\Debug\",
72 " /logger:<logger> Use this logger to log events from MSBuild. To specify",
73 " multiple loggers, specify each logger separately.",
74 " The <logger> syntax is:",
75 " [<logger class>,]<logger assembly>[;<logger parameters>]",
76 " The <logger class> syntax is:",
77 " [<partial or full namespace>.]<logger class name>",
78 " The <logger assembly> syntax is:",
79 " {<assembly name>[,<strong name>] | <assembly file>}",
80 " The <logger parameters> are optional, and are passed",
81 " to the logger exactly as you typed them. (Short form: /l)",
83 " /logger:XMLLogger,MyLogger,Version=1.0.2,Culture=neutral",
84 @" /logger:XMLLogger,C:\Loggers\MyLogger.dll;OutputAsHTML",
86 " /verbosity:<level> Display this amount of information in the event log.",
87 " The available verbosity levels are: q[uiet], m[inimal],",
88 " n[ormal], d[etailed], and diag[nostic]. (Short form: /v)",
92 " /consoleloggerparameters:<parameters>",
93 " Parameters to console logger. (Short form: /clp)",
94 " The available parameters are:",
95 " PerformanceSummary--show time spent in tasks, targets",
97 " NoSummary--don't show error and warning summary at the",
100 " /consoleloggerparameters:PerformanceSummary;NoSummary",
102 " /noconsolelogger Disable the default console logger and do not log events",
103 " to the console. (Short form: /noconlog)",
105 " /validate Validate the project against the default schema. (Short",
108 " /validate:<schema> Validate the project against the specified schema. (Short",
111 " /validate:MyExtendedBuildSchema.xsd",
115 " MSBuild MyApp.sln /t:Rebuild /p:Configuration=Release",
116 " MSBuild MyApp.csproj /t:Clean /p:Configuration=Debug",
120 static string[] version = {
121 "XBuild Engine Version 0.1",
122 String.Format ("Mono, Version {0}", Consts.MonoVersion),
123 "Copyright (C) Marek Sieradzki 2005. All rights reserved.",
127 static public void ReportError (int errorNum, string msg)
129 Console.WriteLine (String.Format ("MSBUILD: error MSBUILD{0:0000}: {1}", errorNum, msg));
130 Environment.Exit (1);
133 static public void ReportWarning (int errorNum, string msg)
135 Console.WriteLine (String.Format ("MSBUILD: warning MSBUILD{0:0000}: {1}", errorNum, msg));
138 static public void ReportInvalidArgument (string option, string value)
140 ReportError (1012, String.Format ("'{0}' is not a valid setting for option '{1}'", value, option));
143 static public void ReportMissingArgument (string option)
145 ReportError (1003, String.Format ("Compiler option '{0}' must be followed by an argument", option));
148 static public void ReportNotImplemented (string option)
150 ReportError (0, String.Format ("Compiler option '{0}' is not implemented", option));
153 static public void ReportMissingFileSpec (string option)
155 ReportError (1008, String.Format ("Missing file specification for '{0}' command-line option", option));
158 static public void ReportMissingText (string option)
160 ReportError (1010, String.Format ("Missing ':<text>' for '{0}' option", option));
163 static public void ShowUsage ()
166 Environment.Exit (0);
170 static public void ShowVersion (bool exit)
174 Environment.Exit (0);
177 static private void Display (string[] array)
179 foreach (string s in array)
180 Console.WriteLine (s);