Beispiel #1
0
        public async Task RunAsync(RunnerOptions options)
        {
            try
            {
                await _outputWriter.StartProgressContext(options, async ctx =>
                {
                    _outputWriter.LogLevel = options.Verbosity;

                    var workspace = await ctx.WithTaskAsync("Loading projects/solutions", task => Workspace.CreateAsync(_outputWriter, options.Solutions, task));
                    await LogWorkspaceSolutionsAsync(workspace);

                    if (options.Undo)
                    {
                        await ctx.WithTaskAsync("Removing ProjectReferences", task => workspace.RemoveReferencesAsync(task));
                        await ctx.WithTaskAsync("Removing projects from solution", task => workspace.CleanupSolutionsAsync(task));
                    }
                    else
                    {
                        await ctx.WithTaskAsync("Adding ProjectReferences for direct references", task => workspace.AddReferencesAsync(task));
                        await ctx.WithTaskAsync("Checking for circular references", task => workspace.CheckForCircularReferences(task));
                        ctx.WithTask("Running NuGet restore", task => workspace.RestoreNugets(options, task));
                        await ctx.WithTaskAsync("Adding ProjectReferences for transitive references", task => workspace.AddTransitiveReferences(options, task));
                        await ctx.WithTaskAsync("Populating solutions", task => workspace.PopulateSolutionsAsync(task));
                    }

                    await ctx.WithTaskAsync("Writing changes", task => workspace.CommitChangesAsync(false, task));
                    _outputWriter.PrintComplete(await workspace.Solutions
                                                .Select(sln => sln.Projects.Value)
                                                .WhenAll(projects => projects.SelectMany(projs => projs)
                                                         .Where(proj => proj.Changes.Any())
                                                         .Count()));
                });
            }
            catch (Exception ex)
            {
                HandleExceptions(ex);
            }
        }