Upgrading to .NET Core 3.0

2019-12-19

I recently migrated from .NET Core 2.0 to .NET Core 3.0 and here's the steps I had to take.

1. Upgrade all project references from 2.0 -> 3.0:

<Project Sdk="Microsoft.NET.Sdk">  
	 <PropertyGroup>    
-		  <TargetFramework>netcoreapp2.0</TargetFramework>    
+		  <TargetFramework>netcoreapp3.0</TargetFramework>  
	 </PropertyGroup> 
.
.
.

2. Upgrade (if required) Newtonsoft.Json (json.net) to 12.0.2

- <PackageReference Include="Newtonsoft.Json" version="10.0.2" /> 
+ <PackageReference Include="Newtonsoft.Json" version="12.0.2" />

3. Change all Partial methods to use PartialAsync with await

- @@Html.Partial("~/Views/Shared/Partial/navigation.cshtml") 
+ @await Html.PartialAsync("~/Views/Shared/Partial/navigation.cshtml")

4. I replaced the razor extension method in Startup.cs with the following csproj entry

+ <AddRazorSupportForMvc>true</AddRazorSupportForMvc>

5. I replaced the .UseApplicationInsights method with .AddApplicationInsightsTelemetry in Program.cs

+ .UseApplicationInsights() 
- .AddApplicationInsightsTelemetry()

6. I made several changes in the Startup.cs file as certain types were no longer available

- public Startup(IConfiguration configuration, IHostingEnvironment env) 
+ public Startup(IConfiguration configuration, IWebHostEnvironment env) 
{ 
}
+ services.AddMvc().AddNewtonsoftJson();
private void Configure(IApplicationBuilder app) 
{ 
-	 app.UseMvc(routes => 
+	 app.UseEndpoints(endpoints => 
	{ 
		endpoints.MapControllerRoute( 
			name: "default", 
			pattern: "{controller=Home}/{action=Index}/{id?}"); 
	}); 
}

7. Also for an extra slice. I added the following package into project to allow for bundling and minification on a dotnet build

<PackageReference Include="BuildBundlerMinifier" Version="3.2.435" />