public static bool RunWithArgs(params string[] args) { if (args.Length > 1) { Console.WriteLine(""); Console.WriteLine($"{ Application.ProductName } { Application.ProductVersion } (build { UpdateService.CurrentBuild })"); Console.WriteLine("--------------------------------"); } var plugins = LoadPlugins(); SetupLibraries(plugins); CommandLineMode = true; CommandLine = new CommandLineHandler(); if (args.Length > 1 && CommandLine.HandleCommandLine(args)) { if (CommandLine.EnableVSTS) { Console.WriteLine("##vso[task.complete result={0};]Done.", CommandLine.ErrorCount > 0 ? "Failed" : ((CommandLine.WarningCount > 0) ? "SucceededWithIssues" : "Succeeded")); } Environment.ExitCode = CommandLine.ErrorCount > 0 ? 1 : 0; return(false); } CommandLineMode = false; return(true); }
public static CommandLineResult CommandLine(params string[] args) { var handler = new CommandLineHandler(); var argsList = new List <string>(); argsList.Add(Environment.CurrentDirectory); argsList.AddRange(args); var stringWriter = new StringWriter(); var originalOutput = Console.Out; Console.SetOut(stringWriter); handler.HandleCommandLine(argsList.ToArray()); return(new CommandLineResult { ErrorCount = handler.ErrorCount, WarningCount = handler.WarningCount, Output = stringWriter.ToString().Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries) }); }