From 4a605e52446c8d8395057c92db36ea637ea327b5 Mon Sep 17 00:00:00 2001 From: Omair Majid Date: Sat, 25 Jun 2022 17:47:48 -0400 Subject: [PATCH] Port to .NET 6 3.1 will be going EOL at the end of 2022. --- LICENSE | 4 ++-- Program.cs | 34 ++++++++-------------------------- Startup.cs | 35 ----------------------------------- devfile.yaml | 11 ++--------- web.csproj | 10 +++++----- 5 files changed, 17 insertions(+), 77 deletions(-) delete mode 100644 Startup.cs diff --git a/LICENSE b/LICENSE index 5a44503..50c3f75 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2019 Red Hat Inc. and others. +Copyright (c) 2022 Red Hat Inc. and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +SOFTWARE. diff --git a/Program.cs b/Program.cs index 0ec08e6..5502f41 100644 --- a/Program.cs +++ b/Program.cs @@ -1,31 +1,13 @@ -/*--------------------------------------------------------------------------------------------- +/*--------------------------------------------------------------------------------------------- * Copyright (c) Red Hat, Inc. All rights reserved. * Licensed under the MIT License. See LICENSE in the project root for license information. *--------------------------------------------------------------------------------------------*/ -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.Extensions.Configuration; -using Microsoft.Extensions.Logging; -namespace web -{ - public class Program - { - public static void Main(string[] args) - { - BuildWebHost(args).Run(); - } +var builder = WebApplication.CreateBuilder(args); +var app = builder.Build(); - public static IWebHost BuildWebHost(string[] args) => - WebHost.CreateDefaultBuilder(args) - .UseStartup() - .UseUrls("http://0.0.0.0:5000/") - .Build(); - - } -} +app.Urls.Add("http://0.0.0.0:5000/"); + +app.MapGet("/", () => "Hello World!"); + +app.Run(); diff --git a/Startup.cs b/Startup.cs deleted file mode 100644 index 9d60088..0000000 --- a/Startup.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Hosting; -using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.DependencyInjection; - -namespace web -{ - public class Startup - { - // This method gets called by the runtime. Use this method to add services to the container. - // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 - public void ConfigureServices(IServiceCollection services) - { - } - - // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IWebHostEnvironment env) - { - if (env.IsDevelopment()) - { - app.UseDeveloperExceptionPage(); - } - - app.Run(async (context) => - { - await context.Response.WriteAsync("Hello World!"); - }); - } - } -} diff --git a/devfile.yaml b/devfile.yaml index bbd05b2..9ed709b 100644 --- a/devfile.yaml +++ b/devfile.yaml @@ -19,21 +19,14 @@ components: volume: size: 1G commands: - - id: 1-update-dependencies - exec: - component: tools - workingDir: ${PROJECTS_ROOT}/dotnet-web-simple - commandLine: "dotnet restore" - group: - kind: build - - id: 2-build + - id: 1-build exec: component: tools workingDir: ${PROJECTS_ROOT}/dotnet-web-simple commandLine: "dotnet build" group: kind: build - - id: 3-run + - id: 2-run exec: component: tools workingDir: ${PROJECTS_ROOT}/dotnet-web-simple diff --git a/web.csproj b/web.csproj index 4eb1175..7381f2e 100644 --- a/web.csproj +++ b/web.csproj @@ -4,14 +4,14 @@ * Licensed under the MIT License. See LICENSE in the project root for license information. ************************************************************************************************ --> + - netcoreapp3.1 - InProcess + net6.0 + enable + enable + web - - -