Migrating to netcore 3.1

This commit is contained in:
Zoe Roux 2019-12-07 17:14:18 +01:00
parent b7e7a676f2
commit 019efafc46
3 changed files with 18 additions and 23 deletions

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework> <TargetFramework>netcoreapp3.1</TargetFramework>
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked> <TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
<TypeScriptToolsVersion>Latest</TypeScriptToolsVersion> <TypeScriptToolsVersion>Latest</TypeScriptToolsVersion>
<IsPackable>false</IsPackable> <IsPackable>false</IsPackable>
@ -16,17 +16,6 @@
<StartupObject>Kyoo.Program</StartupObject> <StartupObject>Kyoo.Program</StartupObject>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNet.WebApi.Core" Version="5.2.7" />
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.1.2" PrivateAssets="All" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="2.1.1" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.1.10" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
<PackageReference Include="System.Data.SQLite" Version="1.0.111" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<!-- Don't publish the SPA source files, but do show them in the project files list --> <!-- Don't publish the SPA source files, but do show them in the project files list -->
<Content Remove="$(SpaRoot)**" /> <Content Remove="$(SpaRoot)**" />
@ -79,6 +68,14 @@
<None Include="wwwroot\roboto\sass\roboto.scss" /> <None Include="wwwroot\roboto\sass\roboto.scss" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.0" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices" Version="3.1.0" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="3.1.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="System.Data.SQLite.Core" Version="1.0.112" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<TypeScriptCompile Include="ClientApp\src\models\search-result.ts"> <TypeScriptCompile Include="ClientApp\src\models\search-result.ts">
<SubType>Code</SubType> <SubType>Code</SubType>

View File

@ -2,11 +2,10 @@ using Kyoo.InternalAPI;
using Kyoo.InternalAPI.ThumbnailsManager; using Kyoo.InternalAPI.ThumbnailsManager;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.SpaServices.AngularCli; using Microsoft.AspNetCore.SpaServices.AngularCli;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using System.Web.Http; using Microsoft.Extensions.Hosting;
namespace Kyoo namespace Kyoo
{ {
@ -22,14 +21,14 @@ namespace Kyoo
// This method gets called by the runtime. Use this method to add services to the container. // This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services) public void ConfigureServices(IServiceCollection services)
{ {
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
// In production, the Angular files will be served from this directory // In production, the Angular files will be served from this directory
services.AddSpaStaticFiles(configuration => services.AddSpaStaticFiles(configuration =>
{ {
configuration.RootPath = "ClientApp/dist"; configuration.RootPath = "ClientApp/dist";
}); });
services.AddControllers().AddNewtonsoftJson();
//Services needed in the private and in the public API //Services needed in the private and in the public API
services.AddSingleton<ILibraryManager, LibraryManager>(); services.AddSingleton<ILibraryManager, LibraryManager>();
services.AddSingleton<ITranscoder, Transcoder>(); services.AddSingleton<ITranscoder, Transcoder>();
@ -41,7 +40,7 @@ namespace Kyoo
} }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env) public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{ {
if (env.IsDevelopment()) if (env.IsDevelopment())
{ {
@ -70,12 +69,11 @@ namespace Kyoo
app.UseStaticFiles(); app.UseStaticFiles();
app.UseSpaStaticFiles(); app.UseSpaStaticFiles();
app.UseMvc(routes => app.UseRouting();
app.UseEndpoints(endpoints =>
{ {
routes.MapRoute( endpoints.MapControllerRoute("API Route", "api/{controller=Home}/{action=Index}/{id?}");
name: "API Route",
template: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional });
}); });
app.UseSpa(spa => app.UseSpa(spa =>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework> <TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace>UnitTests</RootNamespace> <RootNamespace>UnitTests</RootNamespace>
<IsPackable>false</IsPackable> <IsPackable>false</IsPackable>