From 70284463226dd6e5856a77fc8c169f16540e9121 Mon Sep 17 00:00:00 2001 From: Steve Smith Date: Thu, 9 Jul 2015 09:15:03 -0400 Subject: [PATCH] Upgrading to beta5 --- .../servers/sample/ServersDemo/global.json | 2 +- .../ServersDemo/src/ServersDemo/Program.cs | 25 +++++++++++-------- .../ServersDemo/src/ServersDemo/Startup.cs | 13 +++++++++- .../ServersDemo/src/ServersDemo/project.json | 12 ++++----- 4 files changed, 33 insertions(+), 19 deletions(-) diff --git a/aspnet/fundamentals/servers/sample/ServersDemo/global.json b/aspnet/fundamentals/servers/sample/ServersDemo/global.json index e4370fd001..58bb789b20 100644 --- a/aspnet/fundamentals/servers/sample/ServersDemo/global.json +++ b/aspnet/fundamentals/servers/sample/ServersDemo/global.json @@ -1,6 +1,6 @@ { "projects": [ "src", "test" ], "sdk": { - "version": "1.0.0-beta4" + "version": "1.0.0-beta5" } } diff --git a/aspnet/fundamentals/servers/sample/ServersDemo/src/ServersDemo/Program.cs b/aspnet/fundamentals/servers/sample/ServersDemo/src/ServersDemo/Program.cs index b1956ccc2f..c0918fe0d6 100644 --- a/aspnet/fundamentals/servers/sample/ServersDemo/src/ServersDemo/Program.cs +++ b/aspnet/fundamentals/servers/sample/ServersDemo/src/ServersDemo/Program.cs @@ -1,7 +1,7 @@ using System; using System.Threading.Tasks; using Microsoft.AspNet.Hosting; -using Microsoft.Framework.ConfigurationModel; +using Microsoft.Framework.Configuration; namespace ServersDemo { @@ -11,20 +11,23 @@ namespace ServersDemo /// public class Program { + private readonly IServiceProvider _serviceProvider; + + public Program(IServiceProvider serviceProvider) + { + _serviceProvider = serviceProvider; + } public Task Main(string[] args) { //Add command line configuration source to read command line parameters. - var config = new Configuration(); - config.AddCommandLine(args); + var builder = new ConfigurationBuilder(); + builder.AddCommandLine(args); + var config = builder.Build(); - var context = new HostingContext() - { - Configuration = config, - ServerFactoryLocation = "Microsoft.AspNet.Server.WebListener", - ApplicationName = "ServersDemo" - }; - - using (new HostingEngine().Start(context)) + using (new WebHostBuilder(_serviceProvider, config) + .UseServer("Microsoft.AspNet.Server.WebListener") + .Build() + .Start()) { Console.WriteLine("Started the server.."); Console.WriteLine("Press any key to stop the server"); diff --git a/aspnet/fundamentals/servers/sample/ServersDemo/src/ServersDemo/Startup.cs b/aspnet/fundamentals/servers/sample/ServersDemo/src/ServersDemo/Startup.cs index d79ba93c8e..f4bfe9c2e7 100644 --- a/aspnet/fundamentals/servers/sample/ServersDemo/src/ServersDemo/Startup.cs +++ b/aspnet/fundamentals/servers/sample/ServersDemo/src/ServersDemo/Startup.cs @@ -1,12 +1,23 @@ using Microsoft.AspNet.Builder; +using Microsoft.AspNet.Hosting; using Microsoft.AspNet.Http; +using Microsoft.Framework.Configuration; using Microsoft.Framework.DependencyInjection; +using Microsoft.Framework.Runtime; namespace ServersDemo { public class Startup { - // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940 + public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv) + { + // Setup configuration sources. + var builder = new ConfigurationBuilder(appEnv.ApplicationBasePath) + .AddJsonFile("config.json") + .AddEnvironmentVariables(); + Configuration = builder.Build(); + } + public IConfiguration Configuration { get; private set; } public void ConfigureServices(IServiceCollection services) { } diff --git a/aspnet/fundamentals/servers/sample/ServersDemo/src/ServersDemo/project.json b/aspnet/fundamentals/servers/sample/ServersDemo/src/ServersDemo/project.json index df46b899af..9fea84c276 100644 --- a/aspnet/fundamentals/servers/sample/ServersDemo/src/ServersDemo/project.json +++ b/aspnet/fundamentals/servers/sample/ServersDemo/src/ServersDemo/project.json @@ -3,17 +3,17 @@ "version": "1.0.0-*", "dependencies": { - "Microsoft.AspNet.Hosting.Interfaces": "1.0.0-beta4", - "Microsoft.AspNet.Server.IIS": "1.0.0-beta4", - "Microsoft.Framework.ConfigurationModel": "1.0.0-beta4", - "Microsoft.AspNet.Server.WebListener": "1.0.0-beta4", - "Kestrel": "1.0.0-beta4" + "Microsoft.AspNet.Server.IIS": "1.0.0-beta5", + "Microsoft.AspNet.Server.WebListener": "1.0.0-beta5", + "Microsoft.Framework.Configuration.Json": "1.0.0-beta5", + "Kestrel": "1.0.0-beta5" }, "commands": { "kestrel": "Microsoft.AspNet.Hosting --server Kestrel --server.urls http://localhost:5004", "run": "run server.urls=http://localhost:5003", - "web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5000" + "web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5000", + "kestrel2": "Microsoft.AspNet.Hosting --server Kestrel" }, "frameworks": {