From 992407fb35da53658c5c54bf62f06fa163cb02ff Mon Sep 17 00:00:00 2001 From: Mike Harder Date: Thu, 20 Apr 2017 18:46:34 -0700 Subject: [PATCH] Revert "Update build targets and clean up" This reverts commit 587985b49731a8edcdae885688664819886a84b6. --- build/common.props | 8 +-- samples/SampleApp/Program.cs | 56 ++++++++----------- samples/SampleApp/Startup.cs | 10 ++-- .../Microsoft.AspNetCore.All.csproj | 2 +- .../Microsoft.AspNetCore.RuntimeStore.csproj | 4 +- .../Microsoft.AspNetCore.csproj | 7 ++- src/Microsoft.AspNetCore/WebHost.cs | 27 ++++----- 7 files changed, 53 insertions(+), 61 deletions(-) diff --git a/build/common.props b/build/common.props index 6a1fb41e41..dfd6c25f34 100644 --- a/build/common.props +++ b/build/common.props @@ -6,10 +6,6 @@ Microsoft ASP.NET Core https://github.com/aspnet/MetaPackages git - false - ..\..\build\Key.snk - true - true $(VersionSuffix)-$(BuildNumber) @@ -24,7 +20,7 @@ - + @@ -32,7 +28,6 @@ - @@ -107,6 +102,7 @@ + diff --git a/samples/SampleApp/Program.cs b/samples/SampleApp/Program.cs index 30ba926b95..e78eab19d1 100644 --- a/samples/SampleApp/Program.cs +++ b/samples/SampleApp/Program.cs @@ -1,7 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; +using System; using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; @@ -13,61 +10,54 @@ namespace SampleApp { public static void Main(string[] args) { - HelloWorld(); + //HelloWorld(); - CustomUrl(); + //CustomUrl(); - CustomRouter(); + Router(); - StartupClass(args); + //StartupClass(args); } private static void HelloWorld() { - using (WebHost.Start(context => context.Response.WriteAsync("Hello, World!"))) - { - //host.WaitForShutdown(); // TODO: https://github.com/aspnet/Hosting/issues/1022 - Console.WriteLine("Running HelloWorld: Press any key to shutdown and start the next sample..."); - Console.ReadKey(); - } + var host = WebHost.Start(context => context.Response.WriteAsync("Hello, World!")); + //host.WaitForShutdown(); // TODO: This method needs to be added to Hosting + Console.WriteLine("Press any key to shutdown..."); + Console.ReadKey(); } private static void CustomUrl() { // Changing the listening URL - using (WebHost.Start("http://localhost:8080", context => context.Response.WriteAsync("Hello, World!"))) - { - //host.WaitForShutdown(); // TODO: https://github.com/aspnet/Hosting/issues/1022 - Console.WriteLine("Running CustomUrl: Press any key to shutdown and start the next sample..."); - Console.ReadKey(); - } + var host = WebHost.Start("http://localhost:8080", context => context.Response.WriteAsync("Hello, World!")); + //host.WaitForShutdown(); // TODO: This method needs to be added to Hosting + Console.WriteLine("Press any key to shutdown..."); + Console.ReadKey(); } - private static void CustomRouter() + private static void Router() { // Using a router - using (WebHost.Start(router => router + var host = WebHost.Start(router => router .MapGet("hello/{name}", (req, res, data) => res.WriteAsync($"Hello, {data.Values["name"]}")) .MapGet("goodbye/{name}", (req, res, data) => res.WriteAsync($"Goodbye, {data.Values["name"]}")) .MapGet("throw/{message?}", (req, res, data) => throw new Exception((string)data.Values["message"] ?? "Uh oh!")) .MapGet("{greeting}/{name}", (req, res, data) => res.WriteAsync($"{data.Values["greeting"]}, {data.Values["name"]}")) - .MapGet("", (req, res, data) => res.WriteAsync($"Hello, World!")))) - { - //host.WaitForShutdown(); // TODO: https://github.com/aspnet/Hosting/issues/1022 - Console.WriteLine("Running CustomRouter: Press any key to shutdown and start the next sample..."); - Console.ReadKey(); - } + .MapGet("", (req, res, data) => res.WriteAsync($"Hello, World!")) + ); + //host.WaitForShutdown(); // TODO: This method needs to be added to Hosting + Console.WriteLine("Press any key to shutdown..."); + Console.ReadKey(); } private static void StartupClass(string[] args) { // Using defaults with a Startup class - using (var host = WebHost.CreateDefaultBuilder(args) + var host = WebHost.CreateDefaultBuilder(args) .UseStartup() - .Build()) - { - host.Run(); - } + .Build(); + host.Run(); } } } diff --git a/samples/SampleApp/Startup.cs b/samples/SampleApp/Startup.cs index 287fffd27a..0f8e756160 100644 --- a/samples/SampleApp/Startup.cs +++ b/samples/SampleApp/Startup.cs @@ -1,10 +1,12 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; namespace SampleApp { @@ -14,7 +16,7 @@ namespace SampleApp { } - + public void Configure(IApplicationBuilder app, IHostingEnvironment env) { app.Run(async (context) => diff --git a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj index a8f03f7ce0..3f4f051db9 100644 --- a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj +++ b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj @@ -7,7 +7,7 @@ netstandard1.6 aspnetcore Microsoft.AspNetCore.All - false + false diff --git a/src/Microsoft.AspNetCore.RuntimeStore/Microsoft.AspNetCore.RuntimeStore.csproj b/src/Microsoft.AspNetCore.RuntimeStore/Microsoft.AspNetCore.RuntimeStore.csproj index 23c1cf58ee..6331331da8 100644 --- a/src/Microsoft.AspNetCore.RuntimeStore/Microsoft.AspNetCore.RuntimeStore.csproj +++ b/src/Microsoft.AspNetCore.RuntimeStore/Microsoft.AspNetCore.RuntimeStore.csproj @@ -12,9 +12,9 @@ - + - + \ No newline at end of file diff --git a/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj b/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj index f63370faad..1ce6696c7a 100644 --- a/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj +++ b/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj @@ -3,11 +3,14 @@ + true netstandard1.5 aspnetcore Microsoft.AspNetCore - true - false + false + ..\..\build\Key.snk + true + true diff --git a/src/Microsoft.AspNetCore/WebHost.cs b/src/Microsoft.AspNetCore/WebHost.cs index eca24f56b9..4aa1a87df8 100644 --- a/src/Microsoft.AspNetCore/WebHost.cs +++ b/src/Microsoft.AspNetCore/WebHost.cs @@ -21,16 +21,16 @@ namespace Microsoft.AspNetCore { /// /// Initializes and starts a new with pre-configured defaults. - /// See for details. + /// See for details. /// /// A delegate that handles requests to the application. /// A started that hosts the application. public static IWebHost Start(RequestDelegate app) => - Start(url: null, app: app); + Start(null, app); /// /// Initializes and starts a new with pre-configured defaults. - /// See for details. + /// See for details. /// /// The URL the hosted application will listen on. /// A delegate that handles requests to the application. @@ -40,16 +40,16 @@ namespace Microsoft.AspNetCore /// /// Initializes and starts a new with pre-configured defaults. - /// See for details. + /// See for details. /// /// A delegate that configures the router for handling requests to the application. /// A started that hosts the application. public static IWebHost Start(Action routeBuilder) => - Start(url: null, routeBuilder: routeBuilder); + Start(null, routeBuilder); /// /// Initializes and starts a new with pre-configured defaults. - /// See for details. + /// See for details. /// /// The URL the hosted application will listen on. /// A delegate that configures the router for handling requests to the application. @@ -59,22 +59,22 @@ namespace Microsoft.AspNetCore /// /// Initializes and starts a new with pre-configured defaults. - /// See for details. + /// See for details. /// - /// The delegate that configures the . + /// A delegate that handles requests to the application. /// A started that hosts the application. public static IWebHost StartWith(Action app) => - StartWith(url: null, app: app); + StartWith(null, app); /// /// Initializes and starts a new with pre-configured defaults. - /// See for details. + /// See for details. /// /// The URL the hosted application will listen on. /// The delegate that configures the . /// A started that hosts the application. public static IWebHost StartWith(string url, Action app) => - StartWith(url: url, configureServices: null, app: app); + StartWith(url, null, app); private static IWebHost StartWith(string url, Action configureServices, Action app) { @@ -115,7 +115,7 @@ namespace Microsoft.AspNetCore /// /// The initialized . public static IWebHostBuilder CreateDefaultBuilder() => - CreateDefaultBuilder(args: null); + CreateDefaultBuilder(null); /// /// Initializes a new instance of the class with pre-configured defaults. @@ -139,7 +139,7 @@ namespace Microsoft.AspNetCore var builder = new WebHostBuilder() .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) - .ConfigureAppConfiguration((hostingContext, config) => + .ConfigureConfiguration((hostingContext, config) => { var env = hostingContext.HostingEnvironment; @@ -166,6 +166,7 @@ namespace Microsoft.AspNetCore { logging.AddConsole(); }) + // TODO: Remove this when ANCM injects it by default .UseIISIntegration() .ConfigureServices(services => {