Upgrade to .net5 rc1 and fix all breaking changes in the web api since .net core 2.2

This commit is contained in:
runebaas 2020-09-22 13:06:57 +02:00
parent 482a74839a
commit b743539c74
No known key found for this signature in database
GPG key ID: 2677AF508D0300D6
6 changed files with 27 additions and 29 deletions

View file

@ -10,7 +10,7 @@ variables:
Build: Build:
stage: build stage: build
image: mcr.microsoft.com/dotnet/core/sdk:5.0-focal image: mcr.microsoft.com/dotnet/sdk:5.0
artifacts: artifacts:
expire_in: 1h expire_in: 1h
paths: paths:

View file

@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/core/aspnet:5.0-focal FROM mcr.microsoft.com/dotnet/aspnet:5.0
COPY ./app /app/ COPY ./app /app/

View file

@ -22,7 +22,6 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.8.0" /> <PackageReference Include="CommandLineParser" Version="2.8.0" />
<PackageReference Include="Discord.Net" Version="2.2.0" />
<PackageReference Include="Google.Apis.YouTube.v3" Version="1.45.0.1929" /> <PackageReference Include="Google.Apis.YouTube.v3" Version="1.45.0.1929" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.24" /> <PackageReference Include="HtmlAgilityPack" Version="1.11.24" />
<PackageReference Include="MtgApiManager.Lib" Version="1.2.2" /> <PackageReference Include="MtgApiManager.Lib" Version="1.2.2" />

View file

@ -13,19 +13,19 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.8.0" /> <PackageReference Include="CommandLineParser" Version="2.8.0" />
<PackageReference Include="Discord.Net" Version="2.2.0" /> <PackageReference Include="Discord.Net" Version="2.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.0-preview.8.*" /> <PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.0-rc.1.*" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.0-preview.8.*" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.0-rc.1.*" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="5.0.0-preview.8.*" /> <PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="5.0.0-rc.1.*" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="5.0.0-preview.8.*" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="5.0.0-rc.1.*" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.0-preview.8.*" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.0-rc.1.*" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="5.0.0-preview.8.*" /> <PackageReference Include="Microsoft.Extensions.Configuration" Version="5.0.0-rc.1.*" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0-preview.8.*" /> <PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0-rc.1.*" />
<PackageReference Include="Microsoft.Extensions.Options" Version="5.0.0-preview.8.*" /> <PackageReference Include="Microsoft.Extensions.Options" Version="5.0.0-rc.1.*" />
<PackageReference Include="MyAnimeListSharp" Version="1.3.4" /> <PackageReference Include="MyAnimeListSharp" Version="1.3.4" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="NLog" Version="4.7.2" /> <PackageReference Include="NLog" Version="4.7.2" />
<PackageReference Include="NLog.Config" Version="4.7.2" /> <PackageReference Include="NLog.Config" Version="4.7.2" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="5.0.0-preview8" /> <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="5.0.0-rc1" />
<PackageReference Include="SharpRaven" Version="2.4.0" /> <PackageReference Include="SharpRaven" Version="2.4.0" />
<PackageReference Include="SumoLogic.Logging.NLog" Version="1.0.1.3" /> <PackageReference Include="SumoLogic.Logging.NLog" Version="1.0.1.3" />
</ItemGroup> </ItemGroup>

View file

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net5.0</TargetFramework> <TargetFramework>net5.0</TargetFramework>
@ -10,15 +10,6 @@
<NoWarn>NU1701</NoWarn> <NoWarn>NU1701</NoWarn>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="2.2.7" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Cors" Version="2.2.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Core\Core.csproj" /> <ProjectReference Include="..\Core\Core.csproj" />
</ItemGroup> </ItemGroup>

View file

@ -18,6 +18,9 @@ namespace Geekbot.Web
{ {
public static class WebApiStartup public static class WebApiStartup
{ {
// Using the "Microsoft.NET.Sdk.Web" SDK requires a static main function...
public static void Main() {}
public static void StartWebApi(IGeekbotLogger logger, RunParameters runParameters, CommandService commandService, public static void StartWebApi(IGeekbotLogger logger, RunParameters runParameters, CommandService commandService,
DatabaseContext databaseContext, DiscordSocketClient client, IGlobalSettings globalSettings, IHighscoreManager highscoreManager) DatabaseContext databaseContext, DiscordSocketClient client, IGlobalSettings globalSettings, IHighscoreManager highscoreManager)
{ {
@ -28,22 +31,27 @@ namespace Geekbot.Web
}) })
.ConfigureServices(services => .ConfigureServices(services =>
{ {
services.AddMvc(); services.AddControllers();
services.AddSingleton(commandService);
services.AddSingleton(databaseContext);
services.AddSingleton(client);
services.AddSingleton(globalSettings);
services.AddSingleton(highscoreManager);
services.AddCors(options => services.AddCors(options =>
{ {
options.AddPolicy("AllowSpecificOrigin", options.AddPolicy("AllowSpecificOrigin",
builder => builder.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod()); builder => builder.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod());
}); });
services.AddSingleton(commandService);
services.AddSingleton(databaseContext);
services.AddSingleton(client);
services.AddSingleton(globalSettings);
services.AddSingleton(highscoreManager);
}) })
.Configure(app => .Configure(app =>
{ {
app.UseMvc(); app.UseRouting();
app.UseCors(builder => builder.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod().Build()); app.UseCors(builder => builder.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod().Build());
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}) })
.ConfigureLogging(logging => .ConfigureLogging(logging =>
{ {