public static void Main(string[] args) { var currentDirectory = Directory.GetCurrentDirectory(); var host = new WebHostBuilder() .UseIISIntegration() .UseKestrel() .UseContentRoot(currentDirectory) .UseWebRoot(currentDirectory) .UseStartup<Startup>() .Build(); using (host) { using (var cts = new CancellationTokenSource()) { host.Run((services) => { var orchardHost = new OrchardHost(services, System.Console.In, System.Console.Out, args); orchardHost.Run(); cts.Cancel(); }, cts.Token, "Application started. Press Ctrl+C to shut down."); } } }
//https://github.com/aspnet/Hosting/blob/dev/src/Microsoft.AspNet.Hosting/Program.cs public Task<int> Main(string[] args) { //Add command line configuration source to read command line parameters. var builder = new ConfigurationBuilder().AddCommandLine(args); var config = builder.Build(); var host = new WebHostBuilder(_serviceProvider, config, true) .UseServer("Microsoft.AspNet.Server.Kestrel") .Build(); using (var app = host.Start()) { var orchardHost = new OrchardHost(app.Services, System.Console.In, System.Console.Out, args); return Task.FromResult( (int)orchardHost.Run()); } }
public static void Main(string[] args) { var host = new WebHostBuilder() .UseIISIntegration() .UseKestrel() .UseDefaultHostingConfiguration(args) .UseContentRoot(Directory.GetCurrentDirectory()) .UseStartup<Startup>() .Build(); using (host) { host.Run(); var orchardHost = new OrchardHost(host.Services, System.Console.In, System.Console.Out, args); orchardHost.Run(); } }