Upgrade Asp.net Core 3.x Projects to .NET 5.0
As we all aware of .NET framework roadmap released by Microsoft last year and go forward approach is unified framework solution and .NET 5 is first step towards that goal.
.NET 5 was released last year in November and its already battle tested and I feel like its good time to upgrade our API project to latest version .
Please keep in mind that .NET 5 is supported only until Feb 2022 . Going forward all even releases will have LTS (ex: .NET 6 & .NET 8)
I have a Mid-Size Microservice built using ASP.net Core 3.1 API , EF Core , Serilog and running well in our Production environment . I feel like this Microservice is a good candidate to test out the grounds.
How to upgrade (Steps)
First thing first , make sure you have .NET 5 installed on your machine . If you don`t know how to do so check below
Upgrade Visual studio version (Help -> Check for updates) . Make sure you have version 16.8.3 [Preferred way]
Once upgrade is done , go to command console and check version to make sure you have correct version
Project version upgrade-
Once you have made sure you have correct .NET version , go to you project properties and update version to .NET 5 (as shown below)
Update NuGet Dependencies
After above operation go and update project dependencies . Right click project & click on Manage Nuget packages. Look for packages under update tab and update them as per need ( You can also do this by updating .csproj manually and updating version to 5.X , choice is yours which ever seems easier for you)
Checks Post upgrade
Once you do that make sure to build project (this is fastest way to know , if you have any build error )
If no error then all good , just make sure to test out end points and check if you existing 3rd party feature works (such as Error logging layer , DB layer etc).
For my project it was pretty simple to upgrade .NET 3.X to .NET 5 ,as there is not much complication and you should do it sooner than later .
On a second thought However it could differ for your project before you attempt to upgrade check Microsoft page for breaking changes in .NET 5.0 (https://docs.microsoft.com/en-us/dotnet/core/compatibility/5.0) or just follow the steps as I given above and then if you find any errors check errors on google/Microsoft pages (I like to break it before fix it)
You need to install .NET 5 run time hosting bundle on servers to publish these changes to upper environment (Dev, QA , Stage)