From 9c9e48a7997e2dc158bd2ecedc44bb5a94e5e187 Mon Sep 17 00:00:00 2001 From: Ske Date: Sun, 22 Dec 2019 00:40:57 +0100 Subject: [PATCH] Upgrade to .NET Core 3.1 --- Dockerfile | 7 ++++--- PluralKit.API/PluralKit.API.csproj | 13 +++++-------- PluralKit.API/Startup.cs | 17 ++++++++++------- PluralKit.Bot/PluralKit.Bot.csproj | 2 +- PluralKit.Core/PluralKit.Core.csproj | 2 +- 5 files changed, 21 insertions(+), 20 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0f6b47cd..855737a1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,13 @@ -FROM mcr.microsoft.com/dotnet/core/sdk:2.2-alpine AS build +FROM mcr.microsoft.com/dotnet/core/sdk:3.1-alpine AS build WORKDIR /app COPY . /app RUN dotnet publish -c Release -o out -FROM mcr.microsoft.com/dotnet/core/runtime:2.2-alpine +# TODO: is using aspnet correct here? Required for API but might break Bot +FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-alpine WORKDIR /app -COPY --from=build /app/PluralKit.*/out ./ +COPY --from=build /app/PluralKit.*/bin/Release/netcoreapp3.1 ./ ENTRYPOINT ["dotnet"] CMD ["PluralKit.Bot.dll"] diff --git a/PluralKit.API/PluralKit.API.csproj b/PluralKit.API/PluralKit.API.csproj index 14117b0e..4f1a137e 100644 --- a/PluralKit.API/PluralKit.API.csproj +++ b/PluralKit.API/PluralKit.API.csproj @@ -1,16 +1,9 @@  - netcoreapp2.2 + netcoreapp3.1 - - - - - - - @@ -19,4 +12,8 @@ <_ContentIncludedByDefault Remove="Properties\launchSettings.json" /> + + + + diff --git a/PluralKit.API/Startup.cs b/PluralKit.API/Startup.cs index afa3ff9a..2547697e 100644 --- a/PluralKit.API/Startup.cs +++ b/PluralKit.API/Startup.cs @@ -1,9 +1,9 @@ -using App.Metrics; -using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; namespace PluralKit.API { @@ -20,9 +20,10 @@ namespace PluralKit.API public void ConfigureServices(IServiceCollection services) { services.AddCors(); - services.AddMvc(opts => { }) - .SetCompatibilityVersion(CompatibilityVersion.Version_2_2) - .AddJsonOptions(opts => { opts.SerializerSettings.BuildSerializerSettings(); }); + services.AddControllers() + .SetCompatibilityVersion(CompatibilityVersion.Latest) + .AddNewtonsoftJson(); + // .AddJsonOptions(opts => { opts.SerializerSettings.BuildSerializerSettings(); }); services .AddTransient() @@ -39,7 +40,7 @@ namespace PluralKit.API } // 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()) { @@ -54,7 +55,9 @@ namespace PluralKit.API //app.UseHttpsRedirection(); app.UseCors(opts => opts.AllowAnyMethod().AllowAnyOrigin().WithHeaders("Content-Type", "Authorization")); app.UseMiddleware(); - app.UseMvc(); + + app.UseRouting(); + app.UseEndpoints(endpoints => endpoints.MapControllers()); } } } \ No newline at end of file diff --git a/PluralKit.Bot/PluralKit.Bot.csproj b/PluralKit.Bot/PluralKit.Bot.csproj index a8244a45..85e73d99 100644 --- a/PluralKit.Bot/PluralKit.Bot.csproj +++ b/PluralKit.Bot/PluralKit.Bot.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp2.2 + netcoreapp3.1 diff --git a/PluralKit.Core/PluralKit.Core.csproj b/PluralKit.Core/PluralKit.Core.csproj index 566aeace..9d558647 100644 --- a/PluralKit.Core/PluralKit.Core.csproj +++ b/PluralKit.Core/PluralKit.Core.csproj @@ -1,7 +1,7 @@  - netcoreapp2.2 + netcoreapp3.1