Exemple #1
0
        public async Task <int> ExecuteAsync(
            string configuration   = null,
            bool force             = false,
            bool includeSource     = false,
            bool interactive       = false,
            bool noBuild           = false,
            bool noRestore         = false,
            bool nologo            = false,
            string output          = null,
            string runtime         = null,
            bool serviceable       = false,
            string verbosity       = null,
            string versionSuffix   = null,
            bool parallel          = false,
            string outputGraph     = null,
            bool warnDowngrade     = false,
            bool disallowDowngrade = false)
        {
            void InitContext()
            {
                var parameters  = _argsExtractor.GetParameters();
                var projectPath = _argsExtractor.GetProjectPath();

                if (string.IsNullOrEmpty(projectPath))
                {
                    throw new InvalidInputException(exitCode: 1, "Project path is required");
                }

                var options = new ProjectPackOptions
                {
                    Parameters = parameters,

                    // dotnet pack
                    ProjectPath   = projectPath,
                    Configuration = configuration,
                    Force         = force,
                    IncludeSource = includeSource,
                    Interactive   = interactive,
                    NoBuild       = noBuild,
                    NoRestore     = noRestore,
                    NoLogo        = nologo,
                    Output        = output,
                    Runtime       = runtime,
                    Serviceable   = serviceable,
                    Verbosity     = verbosity,
                    VersionSuffix = versionSuffix,

                    // dotnet pack-project
                    Parallel          = parallel,
                    OutputGraph       = outputGraph,
                    WarnDowngrade     = warnDowngrade,
                    DisallowDowngrade = disallowDowngrade
                };

                _contextAccessor.Context = new ExecutionContext
                {
                    Options = options
                };
            }

            InitContext();

            var dependencyGraph = await _graphBuilder.BuildAsync();

            var result = _graphAnalyzer.Analyze(dependencyGraph);

            foreach (var processor in _processors)
            {
                _logger.LogInformation("Executing {Processor}", processor.GetType().Name);
                await processor.ProcessAsync(result, dependencyGraph);
            }

            return(0);
        }