private static void Configure(IServiceProvider sp, GitVersionTaskBase task) { var log = sp.GetService <ILog>(); var buildAgent = sp.GetService <ICurrentBuildAgent>(); var gitVersionOptions = sp.GetService <IOptions <GitVersionOptions> >()?.Value; log.AddLogAppender(new MsBuildAppender(task.Log)); if (buildAgent != null) { gitVersionOptions.Output.Add(OutputType.BuildServer); } gitVersionOptions.Settings.NoFetch = gitVersionOptions.Settings.NoFetch || buildAgent != null && buildAgent.PreventFetch(); }
private static IServiceProvider BuildServiceProvider(GitVersionTaskBase task) { var services = new ServiceCollection(); var gitVersionOptions = new GitVersionOptions { WorkingDirectory = task.SolutionDirectory, }; gitVersionOptions.Output.Add(OutputType.BuildServer); services.AddSingleton(Options.Create(gitVersionOptions)); services.AddModule(new GitVersionTaskModule()); services.AddSingleton <IConsole>(new MsBuildAdapter(task.Log)); var sp = services.BuildServiceProvider(); Configure(sp, task); return(sp); }