Contact application - Upgrade Asp.net Core 2.0 to 2.1


In this article, we will look into steps for contact application - upgrade Asp.net Core 2.0 to 2.1, please see my previous articles about how we developed contact application:
  1. ContactApplication using ASP.NET Core Web API, Angular 6.0, and Visual Studio CodePart One:In the article, we will set up ASP.NET Core Web API project, and develop the Web API for contact CRUD operations.
  2. ContactApplication using ASP.NET Core Web API, Angular 6.0, and Visual Studio CodePart Two:In the article, we will setup Angular 6 within ASP.NET Core Web API Project, and develop the contact form & list component using Angular Material UI that will consume Web API which we have created in Part One.
  3. ContactApplication Azure Deployment:In this article, we are going to deploy/host a contact application with Visual Studio code to Azure web apps.

Please note:  Previously we have used Asp.net Core 2.0.3 for contact application, now upgrade to Asp.net Core 2.1.5.

This is download link for Dot Net Core where you can find appreciate version SDK and Runtime, we have installed to dot net core 2.1.5: https://www.microsoft.com/net/download

Please see What's new in ASP.NET Core 2.1 to know new feature about asp.net core 2.1.

Let’s start upgrading process:

Go to root folder of contact-app project.  Open ‘contact-app.csproj’  file:

Now change the target framework to .NET Core 2.1.
  1. <TargetFramework>netcoreapp2.1</TargetFramework>  
Replace the package reference for ‘Microsoft.AspNetCore.All’ with a package reference for ‘Microsoft.AspNetCore.App’ and remove the ‘Version’ attributes on the package reference to ‘Microsoft.AspNetCore.App’, then set ‘Version’ to 2.1.4 for other  package reference.

Please refer this link more detail about ‘Microsoft.AspNetCore.All’ & ‘Microsoft.AspNetCore.App’ meta package:

Remove references to <DotNetCliToolReference> elements.

Save ‘contact-app.csproj’ file and final ‘contact-app.csproj’ file will look as below screenshot:


Now restore the project by enter following command:


Change main program:

In dot net core 2.1, the main replaces the call to ‘BuildWebHost’ with CreateWebHostBuilder. IWebHostBuilder was added to support a new integrationtest infrastructure.
So, we have updated “IWebHostBuilder“ in program.cs file as shown below:
  1. public class Program   
  2. {  
  3.   
  4. public static void Main(string[] args)  
  5. {  
  6.    CreateWebHostBuilder(args).Build().Run();  
  7. }  
  8.   
  9. public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>  
  10.    WebHost.CreateDefaultBuilder(args)    
  11.    .UseStartup<Startup>();  
  12.   
  13. }  

Our application is now upgraded asp.net core 2.1. we can run the application by “dotnet run“ and verify functionality.

Conclusion:
This is how we can upgrade asp.net core 2.0 to 2.1. You can find full code on this Github link:  https://github.com/JayeshAgrawal/contact-app

Please let me know your thoughts.

Comments

Post a Comment

Popular Posts

Contact Application Using ASP.NET Core Web API, Angular 6.0, And Visual Studio Code - Part One

Chat Application using Angular 8, Asp.net Core 2.2.0, Signal R 1.1.0

Send an Email Reminder Notification Based on an Expiration Date using Power Automate

MySQL Data Access API Development Using Express.JS, Node.JS

Contact Application Using ASP.NET Core Web API, Angular 6.0, And Visual Studio Code - Part Two

ReactNative FlatList

SharePoint Interview Questions and Answers - Part Three

Send Email With SharePoint Lookup Columns Data Using Power Automate

Basics Of Node.js Modules