title: Avoid using the WebBulder and use the Startup file
body: <p>I've a .NET Core application that needs to peform operation based on a scheduler.
  I've used the following code which also installs Kestrel but I don't need to use it at all</p>
  <pre><code>  public class Program
      {
          public static void Main(string[] args)
          {
              var processModule = System.AppDomain.CurrentDomain.BaseDirectory;
  
              var assemblyName = Assembly.GetCallingAssembly().GetName();
              var version = assemblyName.Version;
  
              Directory.SetCurrentDirectory(processModule);
  
              var configuration = new ConfigurationBuilder()
                  .AddJsonFile(&quot;appsettings.json&quot;)
                  .Build();
  
              var applicationName = configuration.GetValue&lt;string&gt;(&quot;Properties:Application&quot;);
  
              var logger = new LoggerConfiguration()
                  .ReadFrom.Configuration(configuration).Enrich.WithProperty(&quot;Version&quot;, version).Enrich
                  .WithProperty(&quot;ApplicationName&quot;, applicationName)
                  .CreateLogger();
  
              Log.Logger = logger;
  
              Log.Logger.Information(&quot;Started {ApplicationName} with version : {Version}&quot;, applicationName, version);
              CreateHostBuilder(args).Build().Run();
          }
  
          public static IHostBuilder CreateHostBuilder(string[] args) =&gt;
              Host.CreateDefaultBuilder(args)
                  .ConfigureWebHostDefaults(webBuilder =&gt; { webBuilder.UseStartup&lt;Startup&gt;(); }).UseSerilog()
                  .UseWindowsService();
      }
  </code></pre>
  <p>And the Startup.cs is as follow :</p>
  <pre><code>class Startup
      {
          public Startup(IConfiguration configuration)
          {
              Configuration = configuration;
  
              DataConnection.DefaultSettings = new Linq2DBSettings(configuration);
          }
  
          public IConfiguration Configuration { get; }
  
          // This method gets called by the runtime. Use this method to add services to the container.
          public void ConfigureServices(IServiceCollection services)
          {
       //OMISS
          }
  
          // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
          public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
          {
          }
      }
  </code></pre>
  <p>Is there a way I can have Startup.cs (or IServiceCollection ) so that I can initialize my DI in this way?</p>
  <p>Thanks</p>