Upgrade ASP.NET Core Web 3.1 app to ASP.NET Core 5 Print

  • 0

To Upgrade ASP.NET Core Web 3.1 app to ASP.NET Core 5, follow these steps.

  • Download and install .NET 5 from here.

  • Update Visual Studio 2019 to 16.8. If you are using community edition, then the latest version is 16.9.0.



    Upgrade ASP.NET Core Web 3.1 app to ASP.NET Core 5

 

  • Next, you need to update Project Target Framework to .NET 5. This can be done in 2 ways.
    – Either via editing the project file.
<PropertyGroup>
   <TargetFramework>net5.0</TargetFramework>
   <CopyRefAssembliesToPublishDirectory>false</CopyRefAssembliesToPublishDirectory>
</PropertyGroup>

– OR via updating the target framework from the project properties. For Example:

updating-target-framework-.net-core-5.0

 

  • Once it is done, try to build the project and see there are no errors. Ideally, upgrading the framework should not cause any errors.

  • Finally, upgrade the nuget packages. You need to check if there are any updates available for already referenced nuget package in your project. To check, right click on dependencies and choose manage NuGet Packages.

update-nuget-packages

And in the update tab, you’ll see a list of packages which are available for updates. Like in this case, there is an update available for the “Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation” package.

update-asp-net-core-5.0

 

 

  • Now, rebuild your project or solution to ensure there are no errors or warnings. If there are no errors, then your project is successfully migrated to .NET 5. Run your app to see it is working as expected.

As mentioned earlier, .NET 5.0 is a major release and there are some code breaking changes introduced. So, if you are getting any errors after upgrading the target framework and nuget package, then see this post from Microsoft in which they have listed down all the breaking changes.


Was this answer helpful?

« Back