Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I add the .NET framework 5.0 to Visual Studio Professional 2019?

I have downloaded and installed the new .NET framework 5.0 from this website.

But I would like to know how to add this framework to a project created on Visual Studio 2019 16.8.0.

Note:

  • I have launched VS installer and I have searched for the new framework, but I can't find it.

enter image description here

  • I have already opened: Project -> Properties -> Target Framework.

But the most recent framework that I got is .NET framework 4.8

How can I add the new framework to the target frameworks in Visual Studio 2019?

Update:

I have a conflict now and I would like to know what's the difference between .NET framework SDK and .NET framework Developer pack, I'm wrong in this point.

As mentioned in the link above, there is no .NET framework 5.0 in the developer pack list.

enter image description here enter image description here

Can anyone explain this to me?

like image 388
abdou_dev Avatar asked Nov 18 '20 10:11

abdou_dev


People also ask

What version of Visual Studio do I need for .NET 5?

You must have version 16.8.0 in order to have .Net Core 5.0 Net Core 5.0 in Visual Studio version 16.8.


1 Answers

Download and install the Visual Studio 2019 SDK from the .NET Core releases site.

enter image description here

.NET 5.0 is continued development of .NET Core and it no longer follows the old (.NET 4 and older) targeting pack. Instead, .NET 5 is installed as an SDK into the .NET Core framework & sdk directory structure. For folks who have been doing .NET Core for some time, this feels natural, but coming from .NET 4, it's new.

Create a new .NET Core project type and set the .NET version to .NET 5.0:

enter image description here

There are specific .NET (not .NET Framework) project templates for Winforms and a few other project types. These will also target .NET 5 or .NET Core where appropriate:

enter image description here

Unfortunately, there is no magic wizard to upgrade a .NET 4 project over to .NET 5. The step-by-step guidance can be found here:

  • Winforms Migration from .NET 4 to .NET 5
  • WPF Migration from .NET 4 to .NET 5

Many ASP.NET folks have gone through these steps to move from .NET 4 to .NET Core in the past. There are many blog posts on the issues they bumped into and how they solved that. The process is very similar and there are some tools now to help you along the way.

The main steps are the same for every .NET 4 project:

  • Change your packages.config to <packageReference> format.
  • Change your project file to the new SDK project format.
  • Run the API Compatibility analyzers. This will tell you where to expect breaking changes.
  • Switch the target framework to .NET 5 in the project file
  • Update/change/add required nuget packages to the versions that support .NET Core/.NET 5.
  • Fix any build issues.

Alternatively:

  • Create a new .NET 5 project of the desired target type.
  • Add the required project configurations etc.
  • Add the NuGet Packages you're going to need.
  • Copy the sources over from your .NET 4 project. Or copy the project file into the folder where your existing project resides. It should automatically import all source files.
  • Fix build issues

It may be possible there won't be a NuGet package of 3rd party components you use that are compatible with .NET 5. In that case you'll need to either wait for one to be released or find an alternative. Of course, in case of open source projects, you could help them out by porting the package for them and sending a pull request.

The Migration guidance linked above gives you multiple approaches to achieve each step.

like image 194
jessehouwing Avatar answered Sep 18 '22 08:09

jessehouwing