Ejemplo 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);
                }
            }
        }
Ejemplo n.º 2
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);
                }
            }
        }
Ejemplo n.º 3
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);
            }
        }
Ejemplo n.º 4
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);
         }
     }
 }