Upgrade to .NET Core 3.1

This commit is contained in:
Ske 2019-12-22 00:40:57 +01:00
parent 7b55abaacd
commit 9c9e48a799
5 changed files with 21 additions and 20 deletions

View File

@ -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 WORKDIR /app
COPY . /app COPY . /app
RUN dotnet publish -c Release -o out 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 WORKDIR /app
COPY --from=build /app/PluralKit.*/out ./ COPY --from=build /app/PluralKit.*/bin/Release/netcoreapp3.1 ./
ENTRYPOINT ["dotnet"] ENTRYPOINT ["dotnet"]
CMD ["PluralKit.Bot.dll"] CMD ["PluralKit.Bot.dll"]

View File

@ -1,16 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework> <TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Cors" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.HttpsPolicy" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\PluralKit.Core\PluralKit.Core.csproj" /> <ProjectReference Include="..\PluralKit.Core\PluralKit.Core.csproj" />
</ItemGroup> </ItemGroup>
@ -19,4 +12,8 @@
<_ContentIncludedByDefault Remove="Properties\launchSettings.json" /> <_ContentIncludedByDefault Remove="Properties\launchSettings.json" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.0" />
</ItemGroup>
</Project> </Project>

View File

@ -1,9 +1,9 @@
using App.Metrics; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace PluralKit.API namespace PluralKit.API
{ {
@ -20,9 +20,10 @@ namespace PluralKit.API
public void ConfigureServices(IServiceCollection services) public void ConfigureServices(IServiceCollection services)
{ {
services.AddCors(); services.AddCors();
services.AddMvc(opts => { }) services.AddControllers()
.SetCompatibilityVersion(CompatibilityVersion.Version_2_2) .SetCompatibilityVersion(CompatibilityVersion.Latest)
.AddJsonOptions(opts => { opts.SerializerSettings.BuildSerializerSettings(); }); .AddNewtonsoftJson();
// .AddJsonOptions(opts => { opts.SerializerSettings.BuildSerializerSettings(); });
services services
.AddTransient<IDataStore, PostgresDataStore>() .AddTransient<IDataStore, PostgresDataStore>()
@ -39,7 +40,7 @@ namespace PluralKit.API
} }
// 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())
{ {
@ -54,7 +55,9 @@ namespace PluralKit.API
//app.UseHttpsRedirection(); //app.UseHttpsRedirection();
app.UseCors(opts => opts.AllowAnyMethod().AllowAnyOrigin().WithHeaders("Content-Type", "Authorization")); app.UseCors(opts => opts.AllowAnyMethod().AllowAnyOrigin().WithHeaders("Content-Type", "Authorization"));
app.UseMiddleware<TokenAuthService>(); app.UseMiddleware<TokenAuthService>();
app.UseMvc();
app.UseRouting();
app.UseEndpoints(endpoints => endpoints.MapControllers());
} }
} }
} }

View File

@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework> <TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework> <TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>