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:
- 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.
- 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.
- 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.
- <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:
- Microsoft.AspNetCore.Allmetapackage for ASP.NET Core 2.0
- Microsoft.AspNetCore.Appmetapackage for ASP.NET Core 2.1 and later.
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:
- public class Program
- {
- public static void Main(string[] args)
- {
- CreateWebHostBuilder(args).Build().Run();
- }
- public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
- WebHost.CreateDefaultBuilder(args)
- .UseStartup<Startup>();
- }
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.
Now finally we found very great article and codes click here Costco Photo Promo Code
ReplyDelete