Updating to netcoreapp3.1 (#199)

This commit is contained in:
Samuele Resca 2020-05-05 22:37:23 +01:00 committed by GitHub
parent 6b537bccbc
commit eaed98f6dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 20 additions and 40 deletions

View File

@ -4,9 +4,6 @@
// ------------------------------------------------------------ // ------------------------------------------------------------
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Subtract.Models; using Subtract.Models;

View File

@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/core/sdk:2.2 AS build-env FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build-env
WORKDIR /app WORKDIR /app
# Copy csproj and restore as distinct layers # Copy csproj and restore as distinct layers
@ -10,7 +10,7 @@ COPY . ./
RUN dotnet publish -c Release -o out RUN dotnet publish -c Release -o out
# Build runtime image # Build runtime image
FROM mcr.microsoft.com/dotnet/core/aspnet:2.2 FROM mcr.microsoft.com/dotnet/core/aspnet:3.1
WORKDIR /app WORKDIR /app
COPY --from=build-env /app/out . COPY --from=build-env /app/out .
ENTRYPOINT ["dotnet", "Subtract.dll"] ENTRYPOINT ["dotnet", "Subtract.dll"]

View File

@ -3,15 +3,8 @@
// Licensed under the MIT License. // Licensed under the MIT License.
// ------------------------------------------------------------ // ------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
namespace Subtract namespace Subtract
{ {
@ -19,11 +12,14 @@ namespace Subtract
{ {
public static void Main(string[] args) public static void Main(string[] args)
{ {
CreateWebHostBuilder(args).Build().Run(); CreateHostBuilder(args).Build().Run();
} }
public static IWebHostBuilder CreateWebHostBuilder(string[] args) => public static IHostBuilder CreateHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args) Host.CreateDefaultBuilder(args)
.UseStartup<Startup>(); .ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
} }
} }

View File

@ -20,7 +20,7 @@
"Subtract": { "Subtract": {
"commandName": "Project", "commandName": "Project",
"launchBrowser": true, "launchBrowser": true,
"launchUrl": "api/values", "launchUrl": "api/subtract",
"applicationUrl": "https://localhost:5001;http://localhost:5000", "applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development"

View File

@ -3,18 +3,11 @@
// Licensed under the MIT License. // Licensed under the MIT License.
// ------------------------------------------------------------ // ------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Options;
namespace Subtract namespace Subtract
{ {
@ -30,22 +23,22 @@ namespace Subtract
// This method gets called by the runtime. Use this method to add services to the container. // This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services) public void ConfigureServices(IServiceCollection services)
{ {
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); services.AddControllers();
} }
// 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())
{ {
app.UseDeveloperExceptionPage(); app.UseDeveloperExceptionPage();
} }
else
{
app.UseHsts();
}
app.UseMvc(); app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
} }
} }
} }

View File

@ -1,16 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework> <TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Folder Include="wwwroot\" /> <Folder Include="wwwroot\" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.1.2" PrivateAssets="All" />
</ItemGroup>
</Project> </Project>