Ejemplo n.º 1
0
        /// <summary>
        /// Steps of execution
        ///    1. Try getting the projectContext for the project
        ///    2. Invoke project dependency command with the first compatible tfm found in the project
        /// </summary>
        internal int Execute(string[] args, bool isNoBuild)
        {
            var  app        = new ScaffoldingApp(false);
            bool isShowHelp = false;

            app.OnExecute(() =>
            {
                try
                {
                    string project = app.ProjectPath.Value();
                    if (string.IsNullOrEmpty(project))
                    {
                        project = Directory.GetCurrentDirectory();
                    }

                    project           = Path.GetFullPath(project);
                    var configuration = app.AppConfiguration.Value() ?? "Debug";

                    isShowHelp = ToolCommandLineHelper.IsHelpArgument(args) ||
                                 app.GeneratorArgument == null ||
                                 string.IsNullOrEmpty(app.GeneratorArgument.Value);

                    ProjectFileFinder projectFileFinder = new ProjectFileFinder(project);

                    if (isShowHelp)
                    {
                        app.ProjectContext = GetProjectInformation(projectFileFinder.ProjectFilePath, configuration);
                        app.ShowHelp();
                        return(0);
                    }
                    // Invoke the tool from the project's build directory.
                    return(BuildAndDispatchDependencyCommand(
                               args,
                               projectFileFinder.ProjectFilePath,
                               app.BuildBasePath.Value(),
                               configuration,
                               isNoBuild,
                               Logger));
                }
                catch (Exception ex)
                {
                    Logger.LogMessage(Resources.GenericErrorMessage, LogMessageLevel.Error);
                    Logger.LogMessage(ex.Message, LogMessageLevel.Error);

                    if (isShowHelp)
                    {
                        app.ShowHelp();
                    }

                    Logger.LogMessage(ex.StackTrace, LogMessageLevel.Trace);
                    if (Logger is ConsoleLogger consoleLogger && !consoleLogger.IsTracing)
                    {
                        Logger.LogMessage(Resources.EnableTracingMessage);
                    }
                    return(-1);
                }
            });

            return(app.Execute(args));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Steps of execution
        ///    1. Try getting the projectContext for the project
        ///    2. Invoke project dependency command with the first compatible tfm found in the project
        /// </summary>
        private static void Execute(string[] args, bool isNoBuild, ILogger logger)
        {
            var app = new ScaffoldingApp(false);

            app.OnExecute(() =>
            {
                string project = app.ProjectPath.Value();
                if (string.IsNullOrEmpty(project))
                {
                    project = Directory.GetCurrentDirectory();
                }

                project           = Path.GetFullPath(project);
                var configuration = app.AppConfiguration.Value() ?? "Debug";

                var projectFileFinder = new ProjectFileFinder(project);

                if (ToolCommandLineHelper.IsHelpArgument(args))
                {
                    app.ProjectContext = GetProjectInformation(projectFileFinder.ProjectFilePath, configuration);
                    app.ShowHelp();
                    return(0);
                }
                // Invoke the tool from the project's build directory.
                return(BuildAndDispatchDependencyCommand(
                           args,
                           projectFileFinder.ProjectFilePath,
                           app.BuildBasePath.Value(),
                           configuration,
                           isNoBuild,
                           logger));
            });

            app.Execute(args);
        }