From d59052acb634fcb2b51bb3febac6aab02e7ee529 Mon Sep 17 00:00:00 2001 From: seprix91 <34176999+seprix91@users.noreply.github.com> Date: Tue, 2 Jan 2018 17:05:39 -0800 Subject: [PATCH] Fixing sample code to use DefaultHostBuilder Though, creating a host from WebHostBuilder is supported approach, it sounds 1.x though. Took liberty to upgrade sample to use more compact static CreateDefaultBuilder method --- .../hosting/windows-service/sample/Program.cs | 25 ++++++++----------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/aspnetcore/hosting/windows-service/sample/Program.cs b/aspnetcore/hosting/windows-service/sample/Program.cs index 0c9b26872a68..759880b0d059 100644 --- a/aspnetcore/hosting/windows-service/sample/Program.cs +++ b/aspnetcore/hosting/windows-service/sample/Program.cs @@ -16,14 +16,11 @@ public static void Main(string[] args) var pathToExe = Process.GetCurrentProcess().MainModule.FileName; var pathToContentRoot = Path.GetDirectoryName(pathToExe); - var host = new WebHostBuilder() - .UseKestrel() - .UseContentRoot(pathToContentRoot) - .UseIISIntegration() - .UseStartup() - .UseApplicationInsights() - .Build(); - + var host = WebHost.CreateDefaultBuilder(args) + .UseContentRoot(pathToContentRoot) + .UseStartup() + .UseApplicationInsights() + .Build(); host.RunAsService(); } #endregion @@ -45,13 +42,11 @@ public static void Main(string[] args) pathToContentRoot = Path.GetDirectoryName(pathToExe); } - var host = new WebHostBuilder() - .UseKestrel() - .UseContentRoot(pathToContentRoot) - .UseIISIntegration() - .UseStartup() - .UseApplicationInsights() - .Build(); + var host = WebHost.CreateDefaultBuilder(args) + .UseContentRoot(pathToContentRoot) + .UseStartup() + .UseApplicationInsights() + .Build(); if (isService) {