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
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"]

View File

@ -1,16 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
</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>
<ProjectReference Include="..\PluralKit.Core\PluralKit.Core.csproj" />
</ItemGroup>
@ -19,4 +12,8 @@
<_ContentIncludedByDefault Remove="Properties\launchSettings.json" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.0" />
</ItemGroup>
</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.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<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.
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<TokenAuthService>();
app.UseMvc();
app.UseRouting();
app.UseEndpoints(endpoints => endpoints.MapControllers());
}
}
}

View File

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

View File

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