Esha Vishwakarma
3 min readMar 7, 2021

--

Hey Everyone,

Hope you are all doing well.

In this article I am sharing my experience with upgrading .NET core version from 3.1 to Net 5.0

Context:
What new features come with .NET 5.0?
Following Microsoft docs on migration would be more than sufficient but there might be some project specific issues with the upgrade, which I would cover later.

What’s needed ?
I did the upgrade on Visual Studio as it provides easier change of TFM (Target Framework) using the “Properties” of the respective projects.
If you are not using Visual Studio, then feel free to follow the step for Visual Code here

Steps:
1. I upgraded my Visual Studio to the latest version (16.8 or later).
2. I already had the ASP.NET and web development workload included.
Visual Studio can install the latest .NET SDK (net 5.0 in this case) and runtime on its own so I didn’t have to download the Net5.0 SDK seperately.

Open and load the project that needs to be migrated.
Right click on the project icon, and goto Properties.

Image credits: Microsoft docs

Once Properties open up, under the “Traget Framework” section, select Net 5.0 from the drop down list of target framework versions.

Image credits: Microsoft Docs

Save and close

Once the TFM has been upgraded, we need to make sure the nuget packages are also upgraded.
To do so, right click on the project as before and goto Manage Nuget Packages.

Image credits: Microsoft Docs

Once the window opens view the section under “Installed” packages and see if the packages have any update once you reset the latest stable version to 5.x

Once the nuget packages have been upgraded, build the project and watchout for any errors.

Note: I’m running on windows and changing the target framework to Net5.0 in my .csproj file was not recognizing some windows functionalities, hence build was failing.

Each .net5.0 and later TFM comes with variations that include OS-specific bindings.
Checkout : https://docs.microsoft.com/en-us/dotnet/standard/frameworks

After changing the TFM from
<PropertyGroup>
- <TargetFramework>netcoreapp3.1</TargetFramework>
+ <TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

to

<PropertyGroup>
- <TargetFramework>netcoreapp3.1</TargetFramework>
+ <TargetFramework>net5.0-windows</TargetFramework>
</PropertyGroup>

My changes were finally accepted and everything built fine.
Using .net5.0-windows will be used to expose Windows-specific functionality, including Windows Forms, WPF and WinRT APIs.

PROFIT

Hope this article helps summarize migration related queries.

Thanks for reading :)

--

--

Esha Vishwakarma

Hey everyone! My name is Esha and I work as a software engineer at Microsoft. I'm new to medium and looking forward to meet new people.