Skip to content

Commit 0f8eccc

Browse files
authored
Merge pull request #6 from cloudscribe/netcore3x-migration
Netcore3x migration
2 parents f0947a2 + bc8ba61 commit 0f8eccc

8 files changed

Lines changed: 77 additions & 96 deletions

File tree

src/WebLib/Properties/AssemblyInfo.cs

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/WebLib/StartupExtensions.cs

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/WebLib/WebLib.csproj

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk.Razor">
22

33
<PropertyGroup>
4-
<TargetFramework>netstandard2.0</TargetFramework>
5-
<AssemblyName>WebLib</AssemblyName>
6-
<PackageId>WebLib</PackageId>
7-
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
8-
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
9-
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
4+
<TargetFramework>netcoreapp3.0</TargetFramework>
5+
<RazorLangVersion>3.0</RazorLangVersion>
6+
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
7+
108
</PropertyGroup>
119

1210
<ItemGroup>
13-
<EmbeddedResource Include="Views\**;MyResources\**;Controllers.OtherController.fr.resx;Controllers.BarController.fr.resx" Exclude="bin\**;obj\**;**\*.xproj;packages\**;@(EmbeddedResource)" />
11+
<FrameworkReference Include="Microsoft.AspNetCore.App" />
1412
</ItemGroup>
1513

14+
1615
<ItemGroup>
17-
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor" Version="2.0.*" />
18-
<PackageReference Include="Microsoft.AspNetCore.Mvc.ViewFeatures" Version="2.0.*" />
19-
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="2.0.*" />
20-
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="2.0.*" />
16+
17+
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="3.0.0-*" />
2118
</ItemGroup>
2219

2320
</Project>

src/cloudscribe.Web.Localization/cloudscribe.Web.Localization.csproj

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22

33
<PropertyGroup>
44
<Description>more flexible localization for ASP.NET Core</Description>
5-
<VersionPrefix>2.0.2</VersionPrefix>
5+
<Version>3.0.0</Version>
66
<Authors>Joe Audette</Authors>
7-
<TargetFrameworks>netstandard2.0</TargetFrameworks>
8-
<AssemblyName>cloudscribe.Web.Localization</AssemblyName>
7+
<TargetFrameworks>netcoreapp3.0</TargetFrameworks>
98
<PackageId>cloudscribe.Web.Localization</PackageId>
109
<PackageTags>cloudscribe;localization;resx</PackageTags>
1110
<PackageIconUrl>https://raw.githubusercontent.com/joeaudette/cloudscribe/master/cloudscribe-icon-32.png</PackageIconUrl>
@@ -17,11 +16,12 @@
1716
</PropertyGroup>
1817

1918
<ItemGroup>
20-
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="2.1.1" />
21-
<PackageReference Include="Microsoft.AspNetCore.Localization" Version="2.1.1" />
22-
<PackageReference Include="Microsoft.AspNetCore.Routing" Version="2.1.1" />
23-
<PackageReference Include="Microsoft.Extensions.Localization" Version="2.1.1" />
24-
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="2.1.1" />
19+
<FrameworkReference Include="Microsoft.AspNetCore.App" />
20+
</ItemGroup>
21+
22+
<ItemGroup>
23+
<PackageReference Include="Microsoft.Extensions.Localization" Version="3.0.0" />
24+
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="3.0.0" />
2525
</ItemGroup>
2626

2727

src/localization.WebApp/Program.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using Microsoft.AspNetCore;
77
using Microsoft.AspNetCore.Hosting;
88
using Microsoft.Extensions.Configuration;
9+
using Microsoft.Extensions.Hosting;
910
using Microsoft.Extensions.Logging;
1011

1112
namespace localization.WebApp
@@ -14,12 +15,14 @@ public class Program
1415
{
1516
public static void Main(string[] args)
1617
{
17-
BuildWebHost(args).Run();
18+
CreateHostBuilder(args).Build().Run();
1819
}
1920

20-
public static IWebHost BuildWebHost(string[] args) =>
21-
WebHost.CreateDefaultBuilder(args)
22-
.UseStartup<Startup>()
23-
.Build();
21+
public static IHostBuilder CreateHostBuilder(string[] args) =>
22+
Host.CreateDefaultBuilder(args)
23+
.ConfigureWebHostDefaults(webBuilder =>
24+
{
25+
webBuilder.UseStartup<Startup>();
26+
});
2427
}
2528
}

src/localization.WebApp/Startup.cs

Lines changed: 45 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
using System.Threading.Tasks;
55
using Microsoft.AspNetCore.Builder;
66
using Microsoft.AspNetCore.Hosting;
7-
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
8-
using Microsoft.EntityFrameworkCore;
7+
//using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
8+
//using Microsoft.EntityFrameworkCore;
99
using Microsoft.Extensions.Configuration;
1010
using Microsoft.Extensions.DependencyInjection;
1111
using Microsoft.Extensions.Logging;
@@ -15,6 +15,7 @@
1515
using Microsoft.Extensions.Options;
1616
using Microsoft.Extensions.Localization;
1717
using cloudscribe.Web.Localization;
18+
using Microsoft.Extensions.Hosting;
1819

1920
//https://github.com/aspnet/Localization/issues/157
2021

@@ -23,7 +24,7 @@ namespace localization.WebApp
2324
public class Startup
2425
{
2526

26-
public Startup(IConfiguration configuration, IHostingEnvironment env)
27+
public Startup(IConfiguration configuration)
2728
{
2829
Configuration =configuration;
2930

@@ -34,6 +35,10 @@ public Startup(IConfiguration configuration, IHostingEnvironment env)
3435
// This method gets called by the runtime. Use this method to add services to the container.
3536
public void ConfigureServices(IServiceCollection services)
3637
{
38+
39+
services.AddControllersWithViews();
40+
services.AddRazorPages();
41+
3742
services.Configure<GlobalResourceOptions>(Configuration.GetSection("GlobalResourceOptions"));
3843
services.AddSingleton<IStringLocalizerFactory, GlobalResourceManagerStringLocalizerFactory>();
3944
//services.AddSingleton<IStringLocalizerFactory, PatchedResourceManagerStringLocalizerFactory>();
@@ -44,7 +49,7 @@ public void ConfigureServices(IServiceCollection services)
4449
services.AddMvc()
4550
.AddRazorOptions(options =>
4651
{
47-
options.AddEmbeddedViewsForWebLib();
52+
//options.AddEmbeddedViewsForWebLib();
4853
})
4954
.AddViewLocalization(LanguageViewLocationExpanderFormat.Suffix)
5055
.AddDataAnnotationsLocalization()
@@ -96,17 +101,16 @@ public void ConfigureServices(IServiceCollection services)
96101

97102
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
98103
public void Configure(
99-
IApplicationBuilder app,
100-
IHostingEnvironment env,
101-
ILoggerFactory loggerFactory,
104+
IApplicationBuilder app,
105+
IWebHostEnvironment env,
102106
IOptions<RequestLocalizationOptions> locOptions
103107
)
104108
{
105109

106110
if (env.IsDevelopment())
107111
{
108112
app.UseDeveloperExceptionPage();
109-
app.UseDatabaseErrorPage();
113+
//app.UseDatabaseErrorPage();
110114

111115
}
112116
else
@@ -119,23 +123,44 @@ IOptions<RequestLocalizationOptions> locOptions
119123

120124
app.UseRequestLocalization(locOptions.Value);
121125

122-
// Add external authentication middleware below. To configure them please see http://go.microsoft.com/fwlink/?LinkID=532715
123-
126+
app.UseHttpsRedirection();
127+
app.UseStaticFiles();
124128

125-
app.UseMvc(routes =>
126-
{
127-
routes.MapRoute(
128-
name: "default-localized",
129-
template: "{culture}/{controller}/{action}/{id?}",
130-
defaults: new { controller = "Home", action = "Index" },
131-
constraints: new { culture = new CultureSegmentRouteConstraint() }
132-
);
129+
app.UseRouting();
133130

131+
app.UseAuthentication();
132+
app.UseAuthorization();
134133

135-
routes.MapRoute(
134+
app.UseEndpoints(endpoints =>
135+
{
136+
endpoints.MapControllerRoute(
137+
name: "default-localized",
138+
pattern: "{culture}/{controller}/{action}/{id?}",
139+
defaults: new { controller = "Home", action = "Index" },
140+
constraints: new { culture = new CultureSegmentRouteConstraint() }
141+
);
142+
143+
endpoints.MapControllerRoute(
136144
name: "default",
137-
template: "{controller=Home}/{action=Index}/{id?}");
145+
pattern: "{controller=Home}/{action=Index}/{id?}");
146+
endpoints.MapRazorPages();
138147
});
148+
149+
150+
//app.UseMvc(routes =>
151+
//{
152+
// routes.MapRoute(
153+
// name: "default-localized",
154+
// template: "{culture}/{controller}/{action}/{id?}",
155+
// defaults: new { controller = "Home", action = "Index" },
156+
// constraints: new { culture = new CultureSegmentRouteConstraint() }
157+
// );
158+
159+
160+
// routes.MapRoute(
161+
// name: "default",
162+
// template: "{controller=Home}/{action=Index}/{id?}");
163+
//});
139164
}
140165
}
141166
}

src/localization.WebApp/localization.WebApp.csproj

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

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp2.1</TargetFramework>
4+
<TargetFramework>netcoreapp3.0</TargetFramework>
55
<UserSecretsId>aspnet-localization.WebApp-940cc8f9-71c6-4716-a22f-dac5c78eb805</UserSecretsId>
66
</PropertyGroup>
77

@@ -16,9 +16,6 @@
1616
<ProjectReference Include="..\cloudscribe.Web.Localization\cloudscribe.Web.Localization.csproj" />
1717
</ItemGroup>
1818

19-
<ItemGroup>
20-
21-
<PackageReference Include="Microsoft.AspNetCore.App" />
22-
</ItemGroup>
19+
2320

2421
</Project>

src/localization.WebApp/web.config

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
-->
66
<system.webServer>
77
<handlers>
8-
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
8+
<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="ASPNETCORE_ENVIRONMENT" value="Development" />
13+
</environmentVariables>
1214
</aspNetCore>
1315
</system.webServer>
1416
</configuration>

0 commit comments

Comments
 (0)