/// <summary> /// Runs the compilation process. /// </summary> /// <param name="args">The compiler arguments passed via the command line.</param> private int Compile(string[] args) { var log = new ConsoleErrorReporter(); using (var parser = new Parser(c => c.HelpWriter = null)) { // Check the arguments for '--help' or '-h' as the command line parser library handles help in a strange // way. If so, output the help screen and successfully terminate the application. if (args.Any(arg => arg == "--help" || arg == "-h")) { log.Info("{0}", GenerateHelpMessage()); return 0; } // If there was an error parsing the command line, show the help screen and terminate the application. if (!parser.ParseArguments(args, this)) { log.Info("{0}", GenerateHelpMessage()); log.Die("Invalid command line arguments."); } } log.Silent = Silent; log.Info(""); log.Info("S# Compiler"); log.Info("Copyright (c) 2014 Institute for Software & Systems Engineering"); log.Info(""); log.Info("This is free software. You may redistribute copies of it under the terms of"); log.Info("the MIT license (see http://opensource.org/licenses/MIT)."); log.Info(""); // Start the compilation process. try { var compiler = new Compiler(log); if (!compiler.Compile(ProjectFile, Configuration, Platform)) return -1; log.Info("Compilation completed successfully."); return 0; } catch (Exception e) { log.Error("A fatal compilation error occurred: {0}", e.Message); #if DEBUG log.Error("StackTrace:\n{0}", e.StackTrace); #endif return -1; } }