示例#1
0
        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();
        }
示例#2
0
        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);
        }