There is no .NET Core 5.0, everything now comes under one umbrella, which is .NET 5 (A Major Release). The idea is to bring all .NET runtimes into a single .NET platform with unified base class libraries (BCL) for all kinds of application like ASP.NET Core, Windows Forms, WPF, Blazor, Xamarin etc. This move now makes .NET a unified platform for all types of .NET applications. If you are working with ASP.NET Core 3.1 app, and planning to upgrade the app to .NET 5 then it’s very easy to upgrade ASP.NET Core Web 3.1 app to ASP.NET Core 5.
Upgrade ASP.NET Core Web 3.1 app to ASP.NET Core 5
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.
- 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. Like,
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.
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.
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.
Thank you for reading. Keep visiting this blog and share this in your network. Please put your thoughts and feedback in the comments section.