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">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
<TypeScriptToolsVersion>Latest</TypeScriptToolsVersion>
<IsPackable>false</IsPackable>
@ -16,17 +16,6 @@
<StartupObject>Kyoo.Program</StartupObject>
</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>
<!-- Don't publish the SPA source files, but do show them in the project files list -->
<Content Remove="$(SpaRoot)**" />
@ -79,6 +68,14 @@
<None Include="wwwroot\roboto\sass\roboto.scss" />
</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>
<TypeScriptCompile Include="ClientApp\src\models\search-result.ts">
<SubType>Code</SubType>

View File

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

View File

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