From 0aa27bbf0bcea6e68246076cab59403cf8e87ce0 Mon Sep 17 00:00:00 2001 From: Will Wolff-Myren Date: Mon, 5 Apr 2021 12:53:53 -0700 Subject: [PATCH 1/4] Upgrade project to .NET Core 3.1 LTS --- src/AdvantageTool.csproj | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/AdvantageTool.csproj b/src/AdvantageTool.csproj index 287d61b..58883ed 100644 --- a/src/AdvantageTool.csproj +++ b/src/AdvantageTool.csproj @@ -1,17 +1,23 @@  - netcoreapp2.2 + netcoreapp3.1 aspnet-AdvantageTool-BDEADEA1-8829-4850-A527-CD895CA0BCC1 /subscriptions/8f07513f-af9b-45df-8f7e-a791be4685d3/resourcegroups/LTI/providers/microsoft.insights/components/AdvantageTool /subscriptions/8f07513f-af9b-45df-8f7e-a791be4685d3/resourcegroups/LTI/providers/microsoft.insights/components/AdvantageTool - - - - + + + + + + + + + + From 90782d92e600777ed21148cd5d53d70929add9c4 Mon Sep 17 00:00:00 2001 From: Will Wolff-Myren Date: Mon, 5 Apr 2021 12:54:15 -0700 Subject: [PATCH 2/4] Add Visual Studio Code configuration files --- .vscode/launch.json | 36 ++++++++++++++++++++++++++++++++++++ .vscode/tasks.json | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 .vscode/launch.json create mode 100644 .vscode/tasks.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..f83a0d9 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,36 @@ +{ + "version": "0.2.0", + "configurations": [ + { + // Use IntelliSense to find out which attributes exist for C# debugging + // Use hover for the description of the existing attributes + // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md + "name": ".NET Core Launch (web)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + // If you have changed target frameworks, make sure to update the program path. + "program": "${workspaceFolder}/src/bin/Debug/netcoreapp2.2/AdvantageTool.dll", + "args": [], + "cwd": "${workspaceFolder}/src", + "stopAtEntry": false, + // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser + "serverReadyAction": { + "action": "openExternally", + "pattern": "\\\\bNow listening on:\\\\s+(https?://\\\\S+)" + }, + "env": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "sourceFileMap": { + "/Views": "${workspaceFolder}/Views" + } + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach", + "processId": "${command:pickProcess}" + } + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..fd544db --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,42 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/src/AdvantageTool.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "publish", + "command": "dotnet", + "type": "process", + "args": [ + "publish", + "${workspaceFolder}/src/AdvantageTool.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "watch", + "command": "dotnet", + "type": "process", + "args": [ + "watch", + "run", + "${workspaceFolder}/src/AdvantageTool.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file From 5f9f221b105ab03a8d1ef26b16543d38b0aad209 Mon Sep 17 00:00:00 2001 From: Will Wolff-Myren Date: Mon, 5 Apr 2021 13:54:58 -0700 Subject: [PATCH 3/4] Replace obsolete method calls with .NET Core 3.1 compatible versions --- .../Identity/Pages/Account/Register.cshtml.cs | 2 +- src/Program.cs | 4 +--- src/Startup.cs | 18 ++++++++++++++---- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/Areas/Identity/Pages/Account/Register.cshtml.cs b/src/Areas/Identity/Pages/Account/Register.cshtml.cs index e73e9a8..a7561b8 100644 --- a/src/Areas/Identity/Pages/Account/Register.cshtml.cs +++ b/src/Areas/Identity/Pages/Account/Register.cshtml.cs @@ -62,7 +62,7 @@ public void OnGet(string returnUrl = null) public async Task OnPostAsync(string returnUrl = null) { - returnUrl = returnUrl ?? Url.Content("~/"); + returnUrl ??= Url.Content("~/"); if (ModelState.IsValid) { var user = new AdvantageToolUser { UserName = Input.Email, Email = Input.Email }; diff --git a/src/Program.cs b/src/Program.cs index 9e1de65..ed35b94 100644 --- a/src/Program.cs +++ b/src/Program.cs @@ -11,8 +11,6 @@ public static void Main(string[] args) } public static IWebHostBuilder CreateWebHostBuilder(string[] args) => - WebHost.CreateDefaultBuilder(args) - .UseApplicationInsights() - .UseStartup(); + WebHost.CreateDefaultBuilder(args).UseStartup(); } } diff --git a/src/Startup.cs b/src/Startup.cs index 22ef0da..85be9f9 100644 --- a/src/Startup.cs +++ b/src/Startup.cs @@ -8,6 +8,7 @@ using AdvantageTool.Utility; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; namespace AdvantageTool { @@ -58,21 +59,24 @@ public void ConfigureServices(IServiceCollection services) services.AddMvc() .AddRazorPagesOptions(options => options.Conventions.AuthorizeFolder("/Platforms")) - .SetCompatibilityVersion(CompatibilityVersion.Version_2_2); + .SetCompatibilityVersion(CompatibilityVersion.Version_3_0); services.AddHttpClient(); + services.AddApplicationInsightsTelemetry(); + services.AddHealthChecks(); + // Make AccessTokenService available for dependency injection. services.AddTransient(); } // 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()) { app.UseDeveloperExceptionPage(); - app.UseDatabaseErrorPage(); + //app.UseDatabaseErrorPage(); // https://github.com/dotnet/efcore/issues/22687#issuecomment-718803655 } else { @@ -85,7 +89,13 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env) app.UseStaticFiles(); app.UseCookiePolicy(); app.UseAuthentication(); - app.UseMvc(); + + app.UseRouting(); + app.UseEndpoints(endpoints => + { + endpoints.MapHealthChecks("/healthcheck"); + endpoints.MapRazorPages(); + }); } } } From 12f7f5cfe8c999af6b87ceb26514d374bf45d016 Mon Sep 17 00:00:00 2001 From: Will Wolff-Myren Date: Mon, 5 Apr 2021 18:44:56 -0700 Subject: [PATCH 4/4] Fix version mismatches and restore app.UseDatabaseErrorPage() --- src/AdvantageTool.csproj | 4 ++-- src/Startup.cs | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/AdvantageTool.csproj b/src/AdvantageTool.csproj index 58883ed..b7a8e23 100644 --- a/src/AdvantageTool.csproj +++ b/src/AdvantageTool.csproj @@ -14,9 +14,9 @@ - + - + diff --git a/src/Startup.cs b/src/Startup.cs index 85be9f9..905c6c5 100644 --- a/src/Startup.cs +++ b/src/Startup.cs @@ -76,7 +76,8 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env) if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); - //app.UseDatabaseErrorPage(); // https://github.com/dotnet/efcore/issues/22687#issuecomment-718803655 + app.UseMigrationsEndPoint(); + app.UseDatabaseErrorPage(); } else { @@ -91,6 +92,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env) app.UseAuthentication(); app.UseRouting(); + app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapHealthChecks("/healthcheck");