Skip to content

Commit 1cb4dd9

Browse files
Partial migration to ASP.NET Core 1.0 RC2 (done the core packages, plus the ES2015/Webpack samples, and the Angular2Spa template). Only verified it builds/runs on .NET Core - not checked on net451.
1 parent 20fd7bc commit 1cb4dd9

File tree

25 files changed

+215
-239
lines changed

25 files changed

+215
-239
lines changed

samples/misc/ES2015Transpilation/Controllers/HomeController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using System.Threading.Tasks;
2-
using Microsoft.AspNet.Mvc;
2+
using Microsoft.AspNetCore.Mvc;
33

44
namespace ES2015Example.Controllers
55
{
Lines changed: 24 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,28 @@
1-
using Microsoft.AspNet.Builder;
2-
using Microsoft.AspNet.Hosting;
1+
using Microsoft.AspNetCore.Builder;
2+
using Microsoft.AspNetCore.Hosting;
3+
using Microsoft.AspNetCore.Http;
34
using Microsoft.AspNet.NodeServices;
4-
using Microsoft.AspNet.Http;
5-
using Microsoft.Extensions.PlatformAbstractions;
6-
using Microsoft.Extensions.Configuration;
75
using Microsoft.Extensions.DependencyInjection;
86
using Microsoft.Extensions.Logging;
7+
using System.IO;
98

109
namespace ES2015Example
1110
{
1211
public class Startup
1312
{
14-
public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
15-
{
16-
// Setup configuration sources.
17-
var builder = new ConfigurationBuilder()
18-
.SetBasePath(appEnv.ApplicationBasePath)
19-
.AddJsonFile("appsettings.json")
20-
.AddEnvironmentVariables();
21-
Configuration = builder.Build();
22-
}
23-
24-
public IConfigurationRoot Configuration { get; set; }
25-
26-
// This method gets called by the runtime.
13+
// This method gets called by the runtime. Use this method to add services to the container.
2714
public void ConfigureServices(IServiceCollection services)
2815
{
29-
// Add MVC services to the services container.
3016
services.AddMvc();
31-
17+
3218
// Enable Node Services
3319
services.AddNodeServices();
3420
}
3521

36-
// Configure is called after ConfigureServices is called.
37-
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, INodeServices nodeServices)
22+
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
23+
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory, IHostingEnvironment env, INodeServices nodeServices)
3824
{
39-
loggerFactory.MinimumLevel = LogLevel.Warning;
40-
loggerFactory.AddConsole();
41-
loggerFactory.AddDebug();
42-
43-
// Configure the HTTP request pipeline.
44-
45-
// Add the platform handler to the request pipeline.
46-
app.UseIISPlatformHandler();
47-
48-
// Add the following to the request pipeline only in development environment.
49-
if (env.IsDevelopment())
50-
{
51-
app.UseDeveloperExceptionPage();
52-
}
53-
else
54-
{
55-
// Add Error handling middleware which catches all application specific errors and
56-
// send the request to the following path or controller action.
57-
app.UseExceptionHandler("/Home/Error");
58-
}
25+
app.UseDeveloperExceptionPage();
5926

6027
// Dynamically transpile any .js files under the '/js/' directory
6128
app.Use(next => async context => {
@@ -73,17 +40,27 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF
7340
await next.Invoke(context);
7441
});
7542

76-
// Add static files to the request pipeline.
7743
app.UseStaticFiles();
78-
79-
// Add MVC to the request pipeline.
44+
loggerFactory.AddConsole();
8045
app.UseMvc(routes =>
8146
{
8247
routes.MapRoute(
8348
name: "default",
84-
template: "{controller}/{action?}/{id?}",
85-
defaults: new { controller="Home", action = "Index" });
49+
template: "{controller=Home}/{action=Index}/{id?}");
8650
});
8751
}
52+
53+
public static void Main(string[] args)
54+
{
55+
var host = new WebHostBuilder()
56+
.UseContentRoot(Directory.GetCurrentDirectory())
57+
.UseDefaultHostingConfiguration(args)
58+
.UseIISPlatformHandlerUrl()
59+
.UseKestrel()
60+
.UseStartup<Startup>()
61+
.Build();
62+
63+
host.Run();
64+
}
8865
}
8966
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
@using ES2015Example
2-
@addTagHelper "*, Microsoft.AspNet.Mvc.TagHelpers"
2+
@addTagHelper "*, Microsoft.AspNetCore.Mvc.TagHelpers"

samples/misc/ES2015Transpilation/project.json

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,35 @@
44
"tooling": {
55
"defaultNamespace": "ES2015Example"
66
},
7+
"compilationOptions": {
8+
"emitEntryPoint": true,
9+
"warningsAsErrors": true,
10+
"preserveCompilationContext": true
11+
},
712
"dependencies": {
8-
"Microsoft.AspNet.Diagnostics": "1.0.0-rc1-*",
9-
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-*",
10-
"Microsoft.AspNet.Mvc": "6.0.0-rc1-*",
11-
"Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-*",
12-
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-*",
13-
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-*",
14-
"Microsoft.AspNet.Tooling.Razor": "1.0.0-rc1-*",
15-
"Microsoft.Extensions.Logging.Console": "1.0.0-rc1-*",
16-
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-*",
13+
"Microsoft.AspNetCore.Diagnostics": "1.0.0-*",
14+
"Microsoft.AspNetCore.IISPlatformHandler": "1.0.0-*",
15+
"Microsoft.AspNetCore.Mvc": "1.0.0-*",
16+
"Microsoft.AspNetCore.Mvc.TagHelpers": "1.0.0-*",
17+
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*",
18+
"Microsoft.AspNetCore.StaticFiles": "1.0.0-*",
19+
"Microsoft.Extensions.Configuration.Json": "1.0.0-*",
20+
"Microsoft.Extensions.Logging.Console": "1.0.0-*",
21+
"Microsoft.NETCore.Platforms": "1.0.1-*",
22+
"Microsoft.Extensions.Logging.Debug": "1.0.0-*",
1723
"Microsoft.AspNet.NodeServices": "1.0.0-*"
1824
},
19-
"commands": {
20-
"web": "Microsoft.AspNet.Server.Kestrel"
21-
},
2225
"frameworks": {
2326
"dnx451": {},
24-
"dnxcore50": {}
27+
"netstandardapp1.5": {
28+
"imports": [
29+
"dnxcore50",
30+
"portable-net451+win8"
31+
],
32+
"dependencies": {
33+
"NETStandard.Library": "1.5.0-*"
34+
}
35+
}
2536
},
2637
"exclude": [
2738
"wwwroot",

samples/misc/Webpack/Controllers/HomeController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using System.Collections.Generic;
33
using System.Linq;
44
using System.Threading.Tasks;
5-
using Microsoft.AspNet.Mvc;
5+
using Microsoft.AspNetCore.Mvc;
66

77
namespace Webpack.Controllers
88
{

samples/misc/Webpack/Startup.cs

Lines changed: 19 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,25 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Threading.Tasks;
5-
using Microsoft.AspNet.Builder;
6-
using Microsoft.AspNet.Hosting;
1+
using Microsoft.AspNetCore.Builder;
2+
using Microsoft.AspNetCore.Hosting;
3+
using Microsoft.AspNetCore.Http;
74
using Microsoft.AspNet.SpaServices.Webpack;
8-
using Microsoft.Extensions.Configuration;
95
using Microsoft.Extensions.DependencyInjection;
106
using Microsoft.Extensions.Logging;
7+
using System.IO;
118

129
namespace Webpack
1310
{
1411
public class Startup
1512
{
16-
public Startup(IHostingEnvironment env)
17-
{
18-
// Set up configuration sources.
19-
var builder = new ConfigurationBuilder()
20-
.AddJsonFile("appsettings.json")
21-
.AddEnvironmentVariables();
22-
Configuration = builder.Build();
23-
}
24-
25-
public IConfigurationRoot Configuration { get; set; }
26-
2713
// This method gets called by the runtime. Use this method to add services to the container.
2814
public void ConfigureServices(IServiceCollection services)
2915
{
30-
// Add framework services.
3116
services.AddMvc();
3217
}
3318

3419
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
35-
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
20+
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory, IHostingEnvironment env)
3621
{
37-
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
38-
loggerFactory.AddDebug();
39-
40-
if (env.IsDevelopment())
41-
{
42-
app.UseDeveloperExceptionPage();
43-
}
44-
else
45-
{
46-
app.UseExceptionHandler("/Home/Error");
47-
}
48-
49-
app.UseIISPlatformHandler();
22+
app.UseDeveloperExceptionPage();
5023

5124
if (env.IsDevelopment()) {
5225
app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions {
@@ -55,7 +28,7 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF
5528
}
5629

5730
app.UseStaticFiles();
58-
31+
loggerFactory.AddConsole();
5932
app.UseMvc(routes =>
6033
{
6134
routes.MapRoute(
@@ -64,7 +37,17 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF
6437
});
6538
}
6639

67-
// Entry point for the application.
68-
public static void Main(string[] args) => Microsoft.AspNet.Hosting.WebApplication.Run<Startup>(args);
40+
public static void Main(string[] args)
41+
{
42+
var host = new WebHostBuilder()
43+
.UseContentRoot(Directory.GetCurrentDirectory())
44+
.UseDefaultHostingConfiguration(args)
45+
.UseIISPlatformHandlerUrl()
46+
.UseKestrel()
47+
.UseStartup<Startup>()
48+
.Build();
49+
50+
host.Run();
51+
}
6952
}
7053
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
@using Webpack
2-
@addTagHelper "*, Microsoft.AspNet.Mvc.TagHelpers"
2+
@addTagHelper "*, Microsoft.AspNetCore.Mvc.TagHelpers"

samples/misc/Webpack/project.json

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
{
22
"version": "1.0.0-*",
33
"compilationOptions": {
4-
"emitEntryPoint": true
4+
"emitEntryPoint": true,
5+
"warningsAsErrors": true,
6+
"preserveCompilationContext": true
57
},
68
"tooling": {
79
"defaultNamespace": "Webpack"
810
},
911

1012
"dependencies": {
11-
"Microsoft.AspNet.Diagnostics": "1.0.0-rc1-final",
12-
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
13-
"Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
14-
"Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-final",
15-
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
16-
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
17-
"Microsoft.AspNet.Tooling.Razor": "1.0.0-rc1-final",
18-
"Microsoft.Extensions.Configuration.FileProviderExtensions" : "1.0.0-rc1-final",
19-
"Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
20-
"Microsoft.Extensions.Logging": "1.0.0-rc1-final",
21-
"Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
22-
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final",
13+
"Microsoft.AspNetCore.Diagnostics": "1.0.0-*",
14+
"Microsoft.AspNetCore.IISPlatformHandler": "1.0.0-*",
15+
"Microsoft.AspNetCore.Mvc": "1.0.0-*",
16+
"Microsoft.AspNetCore.Mvc.TagHelpers": "1.0.0-*",
17+
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*",
18+
"Microsoft.AspNetCore.StaticFiles": "1.0.0-*",
19+
"Microsoft.Extensions.Configuration.Json": "1.0.0-*",
20+
"Microsoft.Extensions.Logging.Console": "1.0.0-*",
21+
"Microsoft.NETCore.Platforms": "1.0.1-*",
22+
"Microsoft.Extensions.Logging.Debug": "1.0.0-*",
2323
"Microsoft.AspNet.SpaServices": "1.0.0-*"
2424
},
2525

@@ -29,7 +29,15 @@
2929

3030
"frameworks": {
3131
"dnx451": {},
32-
"dnxcore50": {}
32+
"netstandardapp1.5": {
33+
"imports": [
34+
"dnxcore50",
35+
"portable-net451+win8"
36+
],
37+
"dependencies": {
38+
"NETStandard.Library": "1.5.0-*"
39+
}
40+
}
3341
},
3442

3543
"exclude": [
@@ -46,10 +54,7 @@
4654
],
4755
"scripts": {
4856
"prepublish": [
49-
"npm install",
50-
"bower install",
51-
"gulp clean",
52-
"gulp min"
57+
"npm install"
5358
]
5459
}
5560
}

src/Microsoft.AspNet.AngularServices/PrimeCacheHelper.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using System.Net;
33
using System.Net.Http;
44
using System.Threading.Tasks;
5-
using Microsoft.AspNet.Mvc.Rendering;
5+
using Microsoft.AspNetCore.Mvc.Rendering;
66
using Microsoft.Extensions.Logging;
77
using Newtonsoft.Json;
88

@@ -25,7 +25,7 @@ public static async Task<HtmlString> PrimeCache(this IHtmlHelper html, string ur
2525
var responseBody = await response.Content.ReadAsStringAsync();
2626
return new HtmlString(FormatAsScript(url, response.StatusCode, responseBody));
2727
} catch (Exception ex) {
28-
var logger = (ILogger)html.ViewContext.HttpContext.ApplicationServices.GetService(typeof (ILogger));
28+
var logger = (ILogger)html.ViewContext.HttpContext.RequestServices.GetService(typeof (ILogger));
2929
if (logger != null) {
3030
logger.LogWarning("Error priming cache for URL: " + url, ex);
3131
}

src/Microsoft.AspNet.AngularServices/project.json

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,19 @@
1313
"defaultNamespace": "Microsoft.AspNet.AngularServices"
1414
},
1515
"frameworks": {
16-
"net451": { },
17-
"dotnet5.4": {
16+
"dnx451": {},
17+
"netstandard1.5": {
18+
"imports": [
19+
"dotnet5.6",
20+
"portable-net451+win8"
21+
],
1822
"dependencies": {
19-
"Microsoft.CSharp": "4.0.1-beta-*",
20-
"System.Collections": "4.0.11-beta-*",
21-
"System.Linq": "4.0.1-beta-*",
22-
"System.Net.Http": "4.0.1-beta-*",
23-
"System.Runtime": "4.0.21-beta-*",
24-
"System.Threading": "4.0.11-beta-*"
2523
}
2624
}
2725
},
2826
"dependencies": {
29-
"Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-final",
30-
"Microsoft.AspNet.NodeServices": "1.0.0-alpha7",
31-
"Microsoft.AspNet.SpaServices": "1.0.0-alpha7-1"
27+
"Microsoft.AspNetCore.Mvc.TagHelpers": "1.0.0-*",
28+
"Microsoft.AspNet.NodeServices": "1.0.0-*",
29+
"Microsoft.AspNet.SpaServices": "1.0.0-*"
3230
}
3331
}

0 commit comments

Comments
 (0)