public static async Task Main()

in plugin-dotnet-agent/src/main/csharp/TeamCity.Dotnet.TestSuppressor/TeamCity.Dotnet.TestSuppressor/Program.cs [28:91]


    public static async Task Main(string[] args)
    {
        Console.WriteLine("TeamCity .NET Test Suppressor");
        Console.WriteLine($"Version: {Version}");
        Console.WriteLine($"Author: {Company}");
        Console.WriteLine();

        var configurationSource = new CommandLineConfigurationSource<MainCommand>(args);

        var host = await Host
            .CreateDefaultBuilder(args)
            .ConfigureAppConfiguration((_, config) => config.Add(configurationSource))
            .ConfigureServices((hostContext, services) =>
            {
                services.Configure<MainCommand>(hostContext.Configuration.GetSection(nameof(MainCommand)));

                // regular services
                services
                    .AddSingleton(configurationSource.ConfigurationParsingResult)
                    .AddSingleton<IFileSystem, FileSystem>()
                    .AddSingletonByInterface<IFileReader>()
                    .AddSingletonByInterface<IFileCopier>()
                    .AddSingletonByInterface<IMsBuildLocator>()
                    .AddSingletonByInterface<IDotnetAssemblyLoader>()
                    .AddSingletonByInterface<ITestSelectorParser>()
                    .AddSingletonByInterface<ITestEngine>()
                    .AddSingletonByImplementationType<ITestEngine>()
                    .AddSingletonByInterface<ITestEngineRecognizer>()
                    .AddSingletonByInterface<ITestClassDetector>()
                    .AddSingletonByInterface<ITestSuppressionDecider>()
                    .AddSingletonByInterface<ITestSuppressionStrategy>()
                    .AddSingletonByInterface<IAssemblyMutator>()
                    .AddSingletonByInterface<ITestsSuppressor>()
                    .AddSingletonByInterface<ITargetResolvingStrategy>()
                    .AddSingletonByInterface<ITargetResolver>()
                    .AddSingletonByInterface<IAssemblyPatcher>()
                    .AddSingletonByInterface<ITestSelectorsLoader>()
                    .AddSingletonByInterface<IBackupMetadataSaver>()
                    .AddSingletonByInterface<IBackupRestore>()
                    .AddSingletonByInterface<IHelpPrinter>()
                    .AddSingletonByInterface<ICommandHandler>()
                    .AddSingletonByInterface<ILoggerConfigurator>()
                    .AddSingletonByInterface<ICommandValidator>()
                    .AddSingleton<CommandRouter<MainCommand>>();
            })
            .ConfigureLogging((_, loggingBuilder) =>
            {
                loggingBuilder
                    .ClearProviders()
                    .AddFilter("Microsoft", LogLevel.Trace)
                    .SetMinimumLevel(LogLevel.Trace)
                    .Services.AddSingleton<ILoggerProvider, CustomLoggerProvider<MainCommand>>();
            })
            .UseConsoleLifetime()
            .StartAsync();

        var commandRouter = host.Services.GetRequiredService<CommandRouter<MainCommand>>();

        // register MSBuild
        host.Services.GetRequiredService<IMsBuildLocator>().RegisterDefaultMsBuild();
        
        // run entry point
        await commandRouter.Route();
    }