static void Main(string[] args) { Dictionary <string, object> defaults = new Dictionary <string, object>(StringComparer.InvariantCultureIgnoreCase) { { "help", false }, { "debug", false }, { "log", false }, { "ip", "localhost" }, { "port", 5000 }, { "reset", false }, { "sandboxed", false }, { "scriptroot", Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\WebEditServer" }, { "start", "http://www.winwrap.com/webedit/" }, { "wwwroot", "" } }; Dictionary <string, object> parameters = WWB.Util.GetParameters(args, defaults); bool help = (bool)parameters["help"]; string error = VerifyWinWrapBasic(); if (error != null) { help = true; } if (help) { if (error == null) { error = ""; } else { error = "\r\n" + error; } parameters[".error"] = error; Console.Write(WWB.Util.ReadResourceTextFile("Messages.Help", parameters)); Console.ReadKey(); return; } bool reset = (bool)parameters["reset"]; bool sandboxed = (bool)parameters["sandboxed"]; string scriptroot = (string)parameters["scriptroot"]; string wwwroot = (string)parameters["wwwroot"]; string log_file = null; if ((bool)parameters["log"]) { log_file = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + WWB.Util.Replace("\\WebEditServer-{port}.txt", parameters); } var hostBuilder = new WebHostBuilder() .UseKestrel(); if (!string.IsNullOrEmpty(wwwroot)) { hostBuilder.UseContentRoot(wwwroot) .UseWebRoot(wwwroot); } var host = hostBuilder.ConfigureLogging((hostingContext, logging) => { logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging")); logging.AddConsole(); logging.AddDebug(); // comment the next line out to get full logging logging.SetMinimumLevel(LogLevel.Critical); }) .UseStartup <Startup>() .UseUrls(WWB.Util.Replace("http://{ip}:{port}", parameters)) .Build(); if ((string)parameters["start"] != "") { string prefix = null; if (!((string)parameters["start"]).StartsWith("http:")) { prefix = WWB.Util.Replace("http://{ip}:{port}/", parameters); } System.Diagnostics.Process.Start(prefix + WWB.Util.Replace("{start}?serverip={ip}:{port}", parameters)); } parameters[".log_file"] = log_file; CancellationTokenSource cts = new CancellationTokenSource(); Console.CancelKeyPress += (s, e) => { e.Cancel = true; cts.Cancel(); }; WinWrapBasicService.Singleton.Initialize(parameters, cts.Token); try { host.Run(); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } finally { WinWrapBasicService.Shutdown(); } }