From 280979c7088133eba5cafaf8d173c7a3f2ec1016 Mon Sep 17 00:00:00 2001 From: SteveSandersonMS Date: Fri, 8 Apr 2016 12:03:05 +0100 Subject: [PATCH] Update ReactSpa template to RC2 --- .../ReactSpa/Controllers/HomeController.cs | 2 +- .../Controllers/SampleDataController.cs | 2 +- templates/ReactSpa/Startup.cs | 57 +++++++------------ templates/ReactSpa/Views/_ViewImports.cshtml | 2 +- templates/ReactSpa/project.json | 38 ++++++++----- 5 files changed, 47 insertions(+), 54 deletions(-) diff --git a/templates/ReactSpa/Controllers/HomeController.cs b/templates/ReactSpa/Controllers/HomeController.cs index 7c59f1e..9d75da8 100755 --- a/templates/ReactSpa/Controllers/HomeController.cs +++ b/templates/ReactSpa/Controllers/HomeController.cs @@ -2,7 +2,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using Microsoft.AspNet.Mvc; +using Microsoft.AspNetCore.Mvc; namespace WebApplicationBasic.Controllers { diff --git a/templates/ReactSpa/Controllers/SampleDataController.cs b/templates/ReactSpa/Controllers/SampleDataController.cs index 45fb312..1f46d12 100644 --- a/templates/ReactSpa/Controllers/SampleDataController.cs +++ b/templates/ReactSpa/Controllers/SampleDataController.cs @@ -2,7 +2,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using Microsoft.AspNet.Mvc; +using Microsoft.AspNetCore.Mvc; namespace WebApplicationBasic.Controllers { diff --git a/templates/ReactSpa/Startup.cs b/templates/ReactSpa/Startup.cs index 99b2c2b..8cd0bfc 100755 --- a/templates/ReactSpa/Startup.cs +++ b/templates/ReactSpa/Startup.cs @@ -1,11 +1,12 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Threading.Tasks; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Hosting; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; using Microsoft.AspNet.SpaServices.Webpack; -using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Newtonsoft.Json.Serialization; @@ -14,21 +15,9 @@ namespace WebApplicationBasic { public class Startup { - public Startup(IHostingEnvironment env) - { - // Set up configuration sources. - var builder = new ConfigurationBuilder() - .AddJsonFile("appsettings.json") - .AddEnvironmentVariables(); - Configuration = builder.Build(); - } - - public IConfigurationRoot Configuration { get; set; } - // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - // Add framework services. services.AddMvc().AddJsonOptions(options => { options.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); @@ -36,33 +25,19 @@ namespace WebApplicationBasic } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) + public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory, IHostingEnvironment env) { - loggerFactory.AddConsole(Configuration.GetSection("Logging")); - loggerFactory.AddDebug(); + app.UseDeveloperExceptionPage(); - if (env.IsDevelopment()) - { - app.UseDeveloperExceptionPage(); - } - else - { - app.UseExceptionHandler("/Home/Error"); - } - - app.UseIISPlatformHandler(); - - if (env.IsDevelopment()) - { - app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions - { + if (env.IsDevelopment()) { + app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions { HotModuleReplacement = true, ReactHotModuleReplacement = true }); } app.UseStaticFiles(); - + loggerFactory.AddConsole(); app.UseMvc(routes => { routes.MapRoute( @@ -75,7 +50,17 @@ namespace WebApplicationBasic }); } - // Entry point for the application. - public static void Main(string[] args) => Microsoft.AspNet.Hosting.WebApplication.Run(args); + public static void Main(string[] args) + { + var host = new WebHostBuilder() + .UseContentRoot(Directory.GetCurrentDirectory()) + .UseDefaultHostingConfiguration(args) + .UseIISPlatformHandlerUrl() + .UseKestrel() + .UseStartup() + .Build(); + + host.Run(); + } } } diff --git a/templates/ReactSpa/Views/_ViewImports.cshtml b/templates/ReactSpa/Views/_ViewImports.cshtml index fc1eb58..5ece85f 100755 --- a/templates/ReactSpa/Views/_ViewImports.cshtml +++ b/templates/ReactSpa/Views/_ViewImports.cshtml @@ -1,3 +1,3 @@ @using WebApplicationBasic -@addTagHelper "*, Microsoft.AspNet.Mvc.TagHelpers" +@addTagHelper "*, Microsoft.AspNetCore.Mvc.TagHelpers" @addTagHelper "*, Microsoft.AspNet.SpaServices" diff --git a/templates/ReactSpa/project.json b/templates/ReactSpa/project.json index 2e909b9..1397e76 100755 --- a/templates/ReactSpa/project.json +++ b/templates/ReactSpa/project.json @@ -1,25 +1,25 @@ { "version": "1.0.0-*", "compilationOptions": { - "emitEntryPoint": true + "emitEntryPoint": true, + "warningsAsErrors": true, + "preserveCompilationContext": true }, "tooling": { "defaultNamespace": "WebApplicationBasic" }, "dependencies": { - "Microsoft.AspNet.Diagnostics": "1.0.0-rc1-final", - "Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final", - "Microsoft.AspNet.Mvc": "6.0.0-rc1-final", - "Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-final", - "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final", - "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final", - "Microsoft.AspNet.Tooling.Razor": "1.0.0-rc1-final", - "Microsoft.Extensions.Configuration.FileProviderExtensions" : "1.0.0-rc1-final", - "Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final", - "Microsoft.Extensions.Logging": "1.0.0-rc1-final", - "Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final", - "Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final", + "Microsoft.AspNetCore.Diagnostics": "1.0.0-*", + "Microsoft.AspNetCore.IISPlatformHandler": "1.0.0-*", + "Microsoft.AspNetCore.Mvc": "1.0.0-*", + "Microsoft.AspNetCore.Mvc.TagHelpers": "1.0.0-*", + "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", + "Microsoft.AspNetCore.StaticFiles": "1.0.0-*", + "Microsoft.Extensions.Configuration.Json": "1.0.0-*", + "Microsoft.Extensions.Logging.Console": "1.0.0-*", + "Microsoft.NETCore.Platforms": "1.0.1-*", + "Microsoft.Extensions.Logging.Debug": "1.0.0-*", "Microsoft.AspNet.ReactServices": "1.0.0-*" }, @@ -29,12 +29,20 @@ "frameworks": { "dnx451": {}, - "dnxcore50": {} + "netstandardapp1.5": { + "imports": [ + "dnxcore50", + "portable-net451+win8" + ], + "dependencies": { + "NETStandard.Library": "1.5.0-*" + } + } }, "exclude": [ "wwwroot", - "node_modules", + "node_modules" ], "publishExclude": [ "node_modules",