From 55d9e6ee4a2d4254b1f9feec92f45f9cb33eab5d Mon Sep 17 00:00:00 2001 From: John Luo Date: Fri, 18 Dec 2015 16:35:11 -0800 Subject: [PATCH] Reacting to new Hosting API --- src/MusicStore/Program.cs | 31 ------------------------------- src/MusicStore/Startup.cs | 11 +++++++++++ src/MusicStore/hosting.json | 3 +++ src/MusicStore/project.json | 8 ++------ 4 files changed, 16 insertions(+), 37 deletions(-) delete mode 100644 src/MusicStore/Program.cs create mode 100644 src/MusicStore/hosting.json diff --git a/src/MusicStore/Program.cs b/src/MusicStore/Program.cs deleted file mode 100644 index 551c07b8ab..0000000000 --- a/src/MusicStore/Program.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using Microsoft.AspNet.Hosting; -using Microsoft.Extensions.Configuration; - -namespace MusicStore -{ - /// - /// This demonstrates how the application can be launched in a console application. - /// "dnx run" command in the application folder will invoke this. - /// - public class Program - { - public static void Main(string[] args) - { - //Add command line configuration source to read command line parameters. - var builder = new ConfigurationBuilder(); - builder.AddCommandLine(args); - var config = builder.Build(); - - using (new WebHostBuilder(config) - .UseServerFactory("Microsoft.AspNet.Server.WebListener") - .Build() - .Start()) - { - Console.WriteLine("Started the server.."); - Console.WriteLine("Press any key to stop the server"); - Console.ReadLine(); - } - } - } -} \ No newline at end of file diff --git a/src/MusicStore/Startup.cs b/src/MusicStore/Startup.cs index fb7b5ca300..3fb99d2cae 100644 --- a/src/MusicStore/Startup.cs +++ b/src/MusicStore/Startup.cs @@ -1,4 +1,5 @@ using Microsoft.AspNet.Builder; +using Microsoft.AspNet.Hosting; using Microsoft.AspNet.Identity.EntityFramework; using Microsoft.Data.Entity; using Microsoft.Extensions.Configuration; @@ -219,5 +220,15 @@ namespace MusicStore //Populates the MusicStore sample data SampleData.InitializeMusicStoreDatabaseAsync(app.ApplicationServices).Wait(); } + + public static void Main(string[] args) + { + var application = new WebApplicationBuilder() + .UseConfiguration(WebApplicationConfiguration.GetDefault(args)) + .UseStartup() + .Build(); + + application.Run(); + } } } \ No newline at end of file diff --git a/src/MusicStore/hosting.json b/src/MusicStore/hosting.json new file mode 100644 index 0000000000..f8ef14574d --- /dev/null +++ b/src/MusicStore/hosting.json @@ -0,0 +1,3 @@ +{ + "server": "Microsoft.AspNet.Server.Kestrel" +} diff --git a/src/MusicStore/project.json b/src/MusicStore/project.json index 2ebb6c2f3a..1815c13b08 100644 --- a/src/MusicStore/project.json +++ b/src/MusicStore/project.json @@ -5,6 +5,7 @@ "description": "Music store application on ASP.NET 5", "version": "1.0.0-*", "compilationOptions": { + "emitEntryPoint": true, "warningsAsErrors": true, "define": [ "DEMO", "TESTING" ] }, @@ -12,7 +13,6 @@ "../../shared/**/*.cs" ], "publishExclude": "*.cmd", - "webroot": "wwwroot", "dependencies": { "EntityFramework.InMemory": "7.0.0-*", "EntityFramework.MicrosoftSqlServer": "7.0.0-*", @@ -39,11 +39,7 @@ "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0-*" }, "commands": { - "gen": "Microsoft.Extensions.CodeGeneration", - "run": "run server.urls=http://localhost:5003", - "web": "Microsoft.AspNet.Server.Kestrel", - "kestrel": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.Kestrel --server.urls http://localhost:5004", - "weblistener": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5002" + "web": "MusicStore" }, "frameworks": { "dnx451": { },