如何将 .NET Framework 5.0 添加到 Visual Studio Professional 2019? [英] How can I add the .NET framework 5.0 to Visual Studio Professional 2019?

查看:76
本文介绍了如何将 .NET Framework 5.0 添加到 Visual Studio Professional 2019?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经下载并安装了

  • 我已经打开了:项目->属性->目标框架.

但我得到的最新框架是 .NET 框架 4.8

如何将新框架添加到 Visual Studio 2019 中的目标框架?

更新:

我现在有冲突,我想知道.NET framework SDK和.NET framework Developer pack有什么区别,我错了.

如上链接所述,开发者包列表中没有 .NET Framework 5.0.

谁能给我解释一下?

解决方案

.NET 5.0 是 .NET Core 的继续开发,它不再遵循旧的(.NET 4 和更早版本)目标包.相反,.NET 5 作为 SDK 安装到 .NET Core 框架和sdk 目录结构.对于已经使用 .NET Core 一段时间的人来说,这感觉很自然,但来自 .NET 4,它是新的.

新建一个.NET Core项目类型并将.NET版本设置为.NET 5.0:

很遗憾,没有将 .NET 4 项目升级到 .NET 5 的魔法向导.可在此处找到分步指南:

过去,许多 ASP.NET 人员已经通过这些步骤从 .NET 4 迁移到 .NET Core.有很多关于他们遇到的问题以及他们如何解决的博客文章.这个过程非常相似,现在有一些工具可以帮助您.

每个 .NET 4 项目的主要步骤都是相同的:

  • 将您的 packages.config 更改为 格式.
  • 将您的项目文件更改为新的 SDK 项目格式.
  • 运行 API 兼容性分析器.这将告诉您哪些地方会发生重大变化.
  • 在项目文件中将目标框架切换到 .NET 5
  • 将所需的 nuget 包更新/更改/添加到支持 .NET Core/.NET 5 的版本.
  • 修复所有构建问题.

或者:

  • 创建所需目标类型的新 .NET 5 项目.
  • 添加所需的项目配置等.
  • 添加您需要的 NuGet 包.
  • 从您的 .NET 4 项目中复制源代码.或者将项目文件复制到现有项目所在的文件夹中.它应该会自动导入所有源文件.
  • 修复构建问题

您使用的 3rd 方组件的 NuGet 包可能与 .NET 5 兼容.在这种情况下,您需要等待一个被释放或寻找替代方案.当然,对于开源项目,您可以通过为他们移植包并发送拉取请求来帮助他们.

上面链接的迁移指南为您提供了实现每个步骤的多种方法.

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.

  • 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.

Can anyone explain this to me?

解决方案

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

.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:

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:

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:

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.

这篇关于如何将 .NET Framework 5.0 添加到 Visual Studio Professional 2019?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆