Skip to content

Commit 99352b3

Browse files
committed
Ported ApplicationParts sample (#326)
1 parent 23cb009 commit 99352b3

File tree

8 files changed

+43
-58
lines changed

8 files changed

+43
-58
lines changed

samples/ApplicationParts/ApplicationParts.Controllers/ApplicationParts.Controllers.csproj

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netstandard2.0</TargetFrameworks>
4+
<TargetFrameworks>netcoreapp3.0</TargetFrameworks>
55
<AssemblyName>ApplicationParts.Controllers</AssemblyName>
66
<PackageId>ApplicationParts.Controllers</PackageId>
77
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
@@ -16,8 +16,7 @@
1616
</ItemGroup>
1717

1818
<ItemGroup>
19-
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.*" />
20-
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="2.2.*" />
19+
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.0.0-*" />
2120
</ItemGroup>
2221

2322
</Project>
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netstandard2.0</TargetFrameworks>
4+
<TargetFrameworks>netcoreapp3.0</TargetFrameworks>
55
<AssemblyName>ApplicationParts.Models</AssemblyName>
66
<PackageId>ApplicationParts.Models</PackageId>
77
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
@@ -11,8 +11,11 @@
1111
</PropertyGroup>
1212

1313
<ItemGroup>
14-
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="2.2.*" />
15-
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.*" />
14+
<FrameworkReference Include="Microsoft.AspNetCore.App" />
15+
</ItemGroup>
16+
17+
<ItemGroup>
18+
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.0.0-*" />
1619
</ItemGroup>
1720

1821
</Project>

samples/ApplicationParts/ApplicationParts.Services/ApplicationParts.Services.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netstandard2.0</TargetFrameworks>
4+
<TargetFrameworks>netcoreapp3.0</TargetFrameworks>
55
<AssemblyName>ApplicationParts.Services</AssemblyName>
66
<PackageId>ApplicationParts.Services</PackageId>
77
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>

samples/ApplicationParts/ApplicationParts.Test/ApplicationParts.Test.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netcoreapp2.2;net461</TargetFrameworks>
4+
<TargetFrameworks>netcoreapp3.0</TargetFrameworks>
55
<PreserveCompilationContext>true</PreserveCompilationContext>
66
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
77
</PropertyGroup>
@@ -16,9 +16,9 @@
1616
</ItemGroup>
1717

1818
<ItemGroup>
19-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
19+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0-*" />
2020
<PackageReference Include="NUnit" Version="3.12.0" />
21-
<PackageReference Include="NUnit3TestAdapter" Version="3.14.0" />
21+
<PackageReference Include="NUnit3TestAdapter" Version="3.15.0" />
2222
</ItemGroup>
2323

2424
</Project>
Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netcoreapp2.2;net461</TargetFrameworks>
4+
<TargetFrameworks>netcoreapp3.0</TargetFrameworks>
55
<AssemblyName>ApplicationParts.Web</AssemblyName>
66
<UserSecretsId>aspnet-ApplicationParts.Web-c273a372-79ef-490d-b0e1-a7fb8f2dacc7</UserSecretsId>
77
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
@@ -18,39 +18,19 @@
1818
</ItemGroup>
1919

2020
<ItemGroup>
21-
<PackageReference Include="Microsoft.AspNetCore" Version="2.2.*" />
22-
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="2.2.*" />
23-
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="2.2.*" />
24-
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.*" />
25-
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="2.2.1" />
26-
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="2.2.*" />
27-
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.*" />
28-
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="2.2.1" />
29-
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.2.*" />
30-
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.2.*" />
31-
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.2.6" />
32-
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.2.6">
21+
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="3.0.0-*" />
22+
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.0.0-*" />
23+
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.0-*" />
24+
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.0.0-*">
3325
<PrivateAssets>all</PrivateAssets>
3426
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
3527
</PackageReference>
36-
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="2.2.4" />
37-
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.2.*" />
38-
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="2.2.*" />
39-
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.2.*" />
40-
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.2.*" />
41-
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.2.*" />
42-
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="2.2.*" />
43-
</ItemGroup>
44-
45-
<Target Name="PrepublishScript" BeforeTargets="PrepareForPublish" Condition=" '$(IsCrossTargetingBuild)' != 'true' ">
46-
<Exec Command="npm install" />
47-
<Exec Command="bower install" />
48-
<Exec Command="gulp clean" />
49-
<Exec Command="gulp min" />
50-
</Target>
51-
52-
<ItemGroup>
53-
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.0" />
28+
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="3.0.0-*" />
29+
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.0.0-*" />
30+
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="3.0.0-*" />
31+
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.0.0-*" />
32+
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="3.0.0-*" />
33+
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.0.0-*" />
5434
</ItemGroup>
5535

5636
</Project>

samples/ApplicationParts/ApplicationParts.Web/Startup.cs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
using Microsoft.EntityFrameworkCore;
1010
using Microsoft.Extensions.Configuration;
1111
using Microsoft.Extensions.DependencyInjection;
12-
using Microsoft.Extensions.Logging;
12+
using Microsoft.Extensions.Hosting;
1313
using Models;
1414
using Services;
1515

1616
public class Startup
1717
{
18-
public Startup(IHostingEnvironment env)
18+
public Startup(IWebHostEnvironment env)
1919
{
2020
var builder = new ConfigurationBuilder()
2121
.SetBasePath(env.ContentRootPath)
@@ -41,7 +41,7 @@ public void ConfigureServices(IServiceCollection services)
4141
.AddDefaultTokenProviders();
4242

4343
services
44-
.AddMvc()
44+
.AddControllersWithViews()
4545
.PartManager
4646
.ApplicationParts
4747
.Add(new AssemblyPart(typeof(HomeController).Assembly));
@@ -50,13 +50,12 @@ public void ConfigureServices(IServiceCollection services)
5050
services.AddTransient<ISmsSender, AuthMessageSender>();
5151
}
5252

53-
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
53+
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
5454
{
5555
if (env.IsDevelopment())
5656
{
5757
app.UseDeveloperExceptionPage();
5858
app.UseDatabaseErrorPage();
59-
app.UseBrowserLink();
6059
}
6160
else
6261
{
@@ -65,18 +64,21 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF
6564

6665
app.UseStaticFiles();
6766

67+
app.UseRouting();
68+
6869
app.UseAuthentication();
69-
70-
app.UseMvc(routes =>
70+
app.UseAuthorization();
71+
72+
app.UseEndpoints(endpoints =>
7173
{
72-
routes.MapRoute(
74+
endpoints.MapControllerRoute(
7375
name: "custom",
74-
template: "CustomRoute",
76+
pattern: "CustomRoute",
7577
defaults: new { controller = "Home", action = "Index" });
7678

77-
routes.MapRoute(
79+
endpoints.MapControllerRoute(
7880
name: "default",
79-
template: "{controller=Home}/{action=Index}/{id?}");
81+
pattern: "{controller=Home}/{action=Index}/{id?}");
8082
});
8183
}
8284
}

samples/ApplicationParts/ApplicationParts.Web/web.config

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@
77
<handlers>
88
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
99
</handlers>
10-
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false">
11-
<environmentVariables />
10+
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" hostingModel="InProcess">
11+
<environmentVariables>
12+
<environmentVariable name="COMPLUS_ForceENC" value="1" />
13+
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
14+
</environmentVariables>
1215
</aspNetCore>
1316
</system.webServer>
1417
</configuration>

test/MyTested.AspNetCore.Mvc.Test.Setups/Startups/RoutingStartup.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@
55

66
public class RoutingStartup
77
{
8-
public void ConfigureServices(IServiceCollection services)
9-
{
10-
services.AddMvc();
11-
}
8+
public void ConfigureServices(IServiceCollection services)
9+
=> services.AddMvc();
1210

1311
public void Configure(IApplicationBuilder app)
1412
{

0 commit comments

Comments
 (0)