Skip to content

Commit 36b18b4

Browse files
Chris Martinezcommonsensesoftware
Chris Martinez
authored andcommitted
ASP.NET Core 2.2 package updates
1 parent f59a929 commit 36b18b4

File tree

52 files changed

+235
-360
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+235
-360
lines changed
Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,18 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp2.0</TargetFramework>
4+
<TargetFramework>netcoreapp2.2</TargetFramework>
5+
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
6+
<RootNamespace>Microsoft.Examples</RootNamespace>
57
</PropertyGroup>
68

79
<ItemGroup>
8-
<Content Update="wwwroot\**\*;Views;Areas\**\Views;appsettings.json;web.config">
9-
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
10-
</Content>
10+
<PackageReference Include="Microsoft.AspNetCore.App" />
11+
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
1112
</ItemGroup>
1213

1314
<ItemGroup>
1415
<ProjectReference Include="..\..\..\src\Microsoft.AspNetCore.Mvc.Versioning\Microsoft.AspNetCore.Mvc.Versioning.csproj" />
1516
</ItemGroup>
1617

17-
<ItemGroup>
18-
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.9" />
19-
</ItemGroup>
20-
21-
<ItemGroup>
22-
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
23-
</ItemGroup>
24-
2518
</Project>

samples/aspnetcore/BasicSample/Controllers/HelloWorldController.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
namespace Microsoft.Examples.Controllers
22
{
3-
using AspNetCore.Mvc.Routing;
43
using AspNetCore.Routing;
5-
using Extensions.DependencyInjection;
64
using Microsoft.AspNetCore.Mvc;
7-
using System;
8-
using System.Collections.Generic;
9-
using System.Linq;
10-
using System.Threading.Tasks;
115

6+
[ApiController]
127
[ApiVersion( "1.0" )]
138
[Route( "api/v{version:apiVersion}/[controller]" )]
14-
public class HelloWorldController : Controller
9+
public class HelloWorldController : ControllerBase
1510
{
1611
// GET api/v{version}/helloworld
1712
[HttpGet]
Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
namespace Microsoft.Examples.Controllers
22
{
33
using Microsoft.AspNetCore.Mvc;
4-
using System;
5-
using System.Collections.Generic;
6-
using System.Linq;
7-
using System.Threading.Tasks;
84

5+
[ApiController]
96
[ApiVersion( "2.0" )]
107
[Route( "api/values" )]
11-
public class Values2Controller : Controller
8+
public class Values2Controller : ControllerBase
129
{
1310
// GET api/values?api-version=2.0
1411
[HttpGet]
15-
public string Get() => $"Controller = {GetType().Name}\nVersion = {HttpContext.GetRequestedApiVersion()}";
12+
public string Get( ApiVersion apiVersion ) => $"Controller = {GetType().Name}\nVersion = {apiVersion}";
1613
}
17-
}
14+
}

samples/aspnetcore/BasicSample/Controllers/ValuesController.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
namespace Microsoft.Examples.Controllers
22
{
33
using Microsoft.AspNetCore.Mvc;
4-
using System;
5-
using System.Collections.Generic;
6-
using System.Linq;
7-
using System.Threading.Tasks;
84

5+
[ApiController]
96
[ApiVersion( "1.0" )]
107
[Route( "api/[controller]" )]
11-
public class ValuesController : Controller
8+
public class ValuesController : ControllerBase
129
{
1310
// GET api/values?api-version=1.0
1411
[HttpGet]
Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,16 @@
11
namespace Microsoft.Examples
22
{
3+
using Microsoft.AspNetCore;
34
using Microsoft.AspNetCore.Builder;
45
using Microsoft.AspNetCore.Hosting;
5-
using System;
6-
using System.Collections.Generic;
7-
using System.IO;
8-
using System.Linq;
9-
using System.Threading.Tasks;
106

11-
public class Program
7+
public static class Program
128
{
13-
public static void Main(string[] args)
14-
{
15-
var host = new WebHostBuilder()
16-
.UseKestrel()
17-
.UseContentRoot(Directory.GetCurrentDirectory())
18-
.UseIISIntegration()
19-
.UseStartup<Startup>()
20-
.Build();
9+
public static void Main( string[] args ) =>
10+
CreateWebHostBuilder( args ).Build().Run();
2111

22-
host.Run();
23-
}
12+
public static IWebHostBuilder CreateWebHostBuilder( string[] args ) =>
13+
WebHost.CreateDefaultBuilder( args )
14+
.UseStartup<Startup>();
2415
}
25-
}
16+
}

samples/aspnetcore/BasicSample/Startup.cs

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,17 @@
44
using Microsoft.AspNetCore.Hosting;
55
using Microsoft.Extensions.Configuration;
66
using Microsoft.Extensions.DependencyInjection;
7-
using Microsoft.Extensions.Logging;
8-
using System;
9-
using System.Collections.Generic;
10-
using System.Linq;
11-
using System.Threading.Tasks;
12-
13-
using Microsoft.AspNetCore.Mvc.Routing;
147

158
public class Startup
169
{
17-
public Startup( IHostingEnvironment env )
10+
public Startup( IConfiguration configuration )
1811
{
19-
var builder = new ConfigurationBuilder()
20-
.SetBasePath( env.ContentRootPath )
21-
.AddJsonFile( "appsettings.json", optional: true, reloadOnChange: true )
22-
.AddJsonFile( $"appsettings.{env.EnvironmentName}.json", optional: true )
23-
.AddEnvironmentVariables();
24-
Configuration = builder.Build();
12+
Configuration = configuration;
2513
}
2614

27-
public IConfigurationRoot Configuration { get; }
15+
public IConfiguration Configuration { get; }
2816

17+
// This method gets called by the runtime. Use this method to add services to the container.
2918
public void ConfigureServices( IServiceCollection services )
3019
{
3120
services.AddMvc();
@@ -34,11 +23,9 @@ public void ConfigureServices( IServiceCollection services )
3423
services.AddApiVersioning( o => o.ReportApiVersions = true );
3524
}
3625

37-
public void Configure( IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory )
26+
public void Configure( IApplicationBuilder app, IHostingEnvironment env )
3827
{
39-
loggerFactory.AddConsole( Configuration.GetSection( "Logging" ) );
40-
loggerFactory.AddDebug();
4128
app.UseMvc();
4229
}
4330
}
44-
}
31+
}
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
{
22
"Logging": {
3-
"IncludeScopes": false,
43
"LogLevel": {
5-
"Default": "Debug",
6-
"System": "Information",
7-
"Microsoft": "Information"
4+
"Default": "Warning"
85
}
9-
}
10-
}
6+
},
7+
"AllowedHosts": "*"
8+
}
Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,18 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp2.0</TargetFramework>
4+
<TargetFramework>netcoreapp2.2</TargetFramework>
5+
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
6+
<RootNamespace>Microsoft.Examples</RootNamespace>
57
</PropertyGroup>
68

79
<ItemGroup>
8-
<Content Update="wwwroot\**\*;Views;Areas\**\Views;appsettings.json;web.config">
9-
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
10-
</Content>
10+
<PackageReference Include="Microsoft.AspNetCore.App" />
11+
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
1112
</ItemGroup>
1213

1314
<ItemGroup>
1415
<ProjectReference Include="..\..\..\src\Microsoft.AspNetCore.Mvc.Versioning\Microsoft.AspNetCore.Mvc.Versioning.csproj" />
1516
</ItemGroup>
1617

17-
<ItemGroup>
18-
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.9" />
19-
</ItemGroup>
20-
21-
<ItemGroup>
22-
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
23-
</ItemGroup>
24-
2518
</Project>
Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,16 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.IO;
4-
using System.Linq;
5-
using System.Threading.Tasks;
6-
using Microsoft.AspNetCore.Hosting;
7-
8-
namespace Microsoft.Examples
1+
namespace Microsoft.Examples
92
{
10-
public class Program
3+
using Microsoft.AspNetCore;
4+
using Microsoft.AspNetCore.Builder;
5+
using Microsoft.AspNetCore.Hosting;
6+
7+
public static class Program
118
{
12-
public static void Main( string[] args )
13-
{
14-
var host = new WebHostBuilder()
15-
.UseKestrel()
16-
.UseContentRoot( Directory.GetCurrentDirectory() )
17-
.UseIISIntegration()
18-
.UseStartup<Startup>()
19-
.Build();
9+
public static void Main( string[] args ) =>
10+
CreateWebHostBuilder( args ).Build().Run();
2011

21-
host.Run();
22-
}
12+
public static IWebHostBuilder CreateWebHostBuilder( string[] args ) =>
13+
WebHost.CreateDefaultBuilder( args )
14+
.UseStartup<Startup>();
2315
}
2416
}

samples/aspnetcore/ByNamespaceSample/Startup.cs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
1-
using Microsoft.AspNetCore.Builder;
2-
using Microsoft.AspNetCore.Hosting;
3-
using Microsoft.AspNetCore.Mvc.Versioning.Conventions;
4-
using Microsoft.Extensions.DependencyInjection;
5-
using Microsoft.Extensions.Logging;
6-
7-
namespace Microsoft.Examples
1+
namespace Microsoft.Examples
82
{
3+
using Microsoft.AspNetCore.Builder;
4+
using Microsoft.AspNetCore.Hosting;
5+
using Microsoft.AspNetCore.Mvc.Versioning.Conventions;
6+
using Microsoft.Extensions.Configuration;
7+
using Microsoft.Extensions.DependencyInjection;
8+
99
public class Startup
1010
{
11+
public Startup( IConfiguration configuration )
12+
{
13+
Configuration = configuration;
14+
}
15+
16+
public IConfiguration Configuration { get; }
17+
1118
// This method gets called by the runtime. Use this method to add services to the container.
12-
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
1319
public void ConfigureServices( IServiceCollection services )
1420
{
1521
services.AddMvc();
@@ -25,15 +31,8 @@ public void ConfigureServices( IServiceCollection services )
2531
}
2632

2733
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
28-
public void Configure( IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory )
34+
public void Configure( IApplicationBuilder app, IHostingEnvironment env )
2935
{
30-
loggerFactory.AddConsole();
31-
32-
if ( env.IsDevelopment() )
33-
{
34-
app.UseDeveloperExceptionPage();
35-
}
36-
3736
app.UseMvc();
3837
}
3938
}

samples/aspnetcore/ByNamespaceSample/V1/Controllers/AgreementsController.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
using Microsoft.AspNetCore.Mvc;
44
using Models;
55

6+
[ApiController]
67
[Route( "[controller]" )]
78
[Route( "v{version:apiVersion}/[controller]" )]
8-
public class AgreementsController : Controller
9+
public class AgreementsController : ControllerBase
910
{
1011
// GET ~/v1/agreements/{accountId}
1112
// GET ~/agreements/{accountId}?api-version=1.0

samples/aspnetcore/ByNamespaceSample/V1/Controllers/OrdersController.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
using Microsoft.AspNetCore.Mvc;
44
using Models;
55

6+
[ApiController]
67
[Route( "[controller]" )]
78
[Route( "v{version:apiVersion}/[controller]" )]
8-
public class OrdersController : Controller
9+
public class OrdersController : ControllerBase
910
{
1011
// GET ~/v1/orders/{accountId}
1112
// GET ~/orders/{accountId}?api-version=1.0

samples/aspnetcore/ByNamespaceSample/V2/Controllers/AgreementsController.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
using Microsoft.AspNetCore.Mvc;
44
using Models;
55

6+
[ApiController]
67
[Route( "[controller]" )]
78
[Route( "v{version:apiVersion}/[controller]" )]
8-
public class AgreementsController : Controller
9+
public class AgreementsController : ControllerBase
910
{
1011
// GET ~/v2/agreements/{accountId}
1112
// GET ~/agreements/{accountId}?api-version=2.0

samples/aspnetcore/ByNamespaceSample/V2/Controllers/OrdersController.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
using Microsoft.AspNetCore.Mvc;
44
using Models;
55

6+
[ApiController]
67
[Route( "[controller]" )]
78
[Route( "v{version:apiVersion}/[controller]" )]
8-
public class OrdersController : Controller
9+
public class OrdersController : ControllerBase
910
{
1011
// GET ~/v2/orders/{accountId}
1112
// GET ~/orders/{accountId}?api-version=2.0

samples/aspnetcore/ByNamespaceSample/V3/Controllers/AgreementsController.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
using Microsoft.AspNetCore.Mvc;
44
using Models;
55

6+
[ApiController]
67
[Route( "[controller]" )]
78
[Route( "v{version:apiVersion}/[controller]" )]
8-
public class AgreementsController : Controller
9+
public class AgreementsController : ControllerBase
910
{
1011
// GET ~/v3/agreements/{accountId}
1112
// GET ~/agreements/{accountId}?api-version=3.0

samples/aspnetcore/ByNamespaceSample/V3/Controllers/OrdersController.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
using Microsoft.AspNetCore.Mvc;
44
using Models;
55

6+
[ApiController]
67
[Route( "[controller]" )]
78
[Route( "v{version:apiVersion}/[controller]" )]
8-
public class OrdersController : Controller
9+
public class OrdersController : ControllerBase
910
{
1011
// GET ~/v3/orders/{accountId}
1112
// GET ~/orders/{accountId}?api-version=3.0
1213
[HttpGet( "{accountId}" )]
1314
public IActionResult Get( string accountId, ApiVersion apiVersion ) => Ok( new Order( GetType().FullName, accountId, apiVersion.ToString() ) );
1415
}
15-
}
16+
}

0 commit comments

Comments
 (0)