Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            _logger = new ConsoleLogger();
            _logger.LogMessage($"Command Line: {string.Join(" ", args)}");

            _isDispatcher = DotnetToolDispatcher.IsDispatcher(args);
            _logger.LogMessage($"Is Dispatcher: {_isDispatcher}", LogMessageLevel.Trace);
            try
            {
                DotnetToolDispatcher.EnsureValidDispatchRecipient(ref args);
                Execute(args);
            }
            finally
            {
                stopWatch.Stop();
                TimeSpan ts          = stopWatch.Elapsed;
                string   elapsedTime = string.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                                                     ts.Hours, ts.Minutes, ts.Seconds,
                                                     ts.Milliseconds / 10);
                if (_isDispatcher)
                {
                    // Check is needed so we don't show the runtime twice (once for the portable process and once for the dependency process)
                    _logger.LogMessage("RunTime " + elapsedTime, LogMessageLevel.Information);
                }
            }
        }
Exemplo n.º 2
0
        public static int Main(string[] args)
        {
            int       exitCode  = -1;
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            var instance = new Program();

            instance.Logger.LogMessage($"Command Line: {string.Join(" ", args)}", LogMessageLevel.Trace);

            _isNoBuild = ToolCommandLineHelper.IsNoBuild(args);
            try
            {
                DotnetToolDispatcher.EnsureValidDispatchRecipient(ref args);
                instance.SkipImportTarget = false;
                exitCode = instance.Execute(args, _isNoBuild);
            }
            finally
            {
                stopWatch.Stop();
                TimeSpan ts          = stopWatch.Elapsed;
                string   elapsedTime = string.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                                                     ts.Hours, ts.Minutes, ts.Seconds,
                                                     ts.Milliseconds / 10);

                instance.Logger.LogMessage("RunTime " + elapsedTime, LogMessageLevel.Information);
            }

            return(exitCode);
        }
Exemplo n.º 3
0
        public static void Main(string[] args)
        {
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            _logger = new ConsoleLogger();
            _logger.LogMessage($"Command Line: {string.Join(" ", args)}", LogMessageLevel.Trace);

            _isNoBuild = ToolCommandLineHelper.IsNoBuild(args);
            try
            {
                DotnetToolDispatcher.EnsureValidDispatchRecipient(ref args);
                Execute(args, _isNoBuild, _logger);
            }
            finally
            {
                stopWatch.Stop();
                TimeSpan ts          = stopWatch.Elapsed;
                string   elapsedTime = string.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                                                     ts.Hours, ts.Minutes, ts.Seconds,
                                                     ts.Milliseconds / 10);

                _logger.LogMessage("RunTime " + elapsedTime, LogMessageLevel.Information);
            }
        }
Exemplo n.º 4
0
        public static int Main([NotNull] string[] args)
        {
            HandleVerboseOption(ref args);
            DebugHelper.HandleDebugSwitch(ref args);

            try
            {
                DotnetToolDispatcher.EnsureValidDispatchRecipient(ref args, ExecuteCommand.GetToolName());
                return(ExecuteCommand.Create().Execute(args));
            }
            catch (Exception ex)
            {
                // TODO ensure always a json response if --json is supplied
                if (ex is TargetInvocationException)
                {
                    ex = ex.InnerException;
                }

                if (!(ex is OperationException))
                {
                    Reporter.Error.WriteLine(ex.ToString());
                }

                Reporter.Error.WriteLine(ex.Message.Bold().Red());
                return(1);
            }
        }
Exemplo n.º 5
0
        public static int Main(string[] args)
        {
            if (DotnetToolDispatcher.IsDispatcher(args))
            {
                Dispatch(args);
                return(0);
            }
            else
            {
                try
                {
                    DotnetToolDispatcher.EnsureValidDispatchRecipient(ref args);
                    return(Worker.Execute(args));
                }
                catch (Exception ex)
                {
                    if (ex is TargetInvocationException)
                    {
                        ex = ex.InnerException;
                    }

                    Console.WriteLine(ex.Message);
                    return(1);
                }
            }
        }
Exemplo n.º 6
0
        public static int Main(string[] args)
        {
            try
            {
                var app = new CommandLineApplication
                {
                    Name               = "razor-tooling",
                    FullName           = "Microsoft Razor Tooling Utility",
                    Description        = "Resolves Razor tooling specific information.",
                    ShortVersionGetter = GetInformationalVersion,
                };
                app.HelpOption("-?|-h|--help");

                ResolveProtocolCommand.Register(app);

                if (DotnetToolDispatcher.IsDispatcher(args))
                {
                    ResolveTagHelpersCommandBase.Register <ResolveTagHelpersDispatchCommand>(app);
                }
                else
                {
                    DotnetToolDispatcher.EnsureValidDispatchRecipient(ref args);

                    ResolveTagHelpersCommandBase.Register <ResolveTagHelpersRunCommand>(app);
                }

                app.OnExecute(() =>
                {
                    app.ShowHelp();
                    return(2);
                });

                return(app.Execute(args));
            }
            catch (Exception ex)
            {
                Reporter.Error.WriteLine(ex.Message);
                return(1);
            }
        }
Exemplo n.º 7
0
 public static int Main(string[] args)
 {
     if (DotnetToolDispatcher.IsDispatcher(args))
     {
         Dispatch(args);
         return(0);
     }
     else
     {
         try
         {
             DotnetToolDispatcher.EnsureValidDispatchRecipient(ref args);
             return(Worker.Execute(args));
         }
         catch (OperationException ex)
         {
             Console.ForegroundColor = ConsoleColor.Red;
             Console.WriteLine(ex.Message);
             return(1);
         }
     }
 }