【问题标题】:How to change .NET Framework to .NET Standard/Core in Visual Studio?如何在 Visual Studio 中将 .NET Framework 更改为 .NET Standard/Core?
【发布时间】:2020-12-22 16:22:51
【问题描述】:

我在 Visual Studios 中有一个 C# 解决方案。它最初是在 .NET Framework 中创建的。我想将项目转换为 .NET Standard/Core。如果我进入项目 --> 属性,我会看到附加的屏幕,其中 Target Framework 是 .NET Framework。我如何才能将其更改为 .NET Standard/Core?

【问题讨论】:

  • 这可能是一个老式的 csproj,是吗?您需要将其转换为新样式(“SDK”样式)csproj。对于简单的项目,这很简单,通常最简单的方法是从头开始创建一个新样式的 csproj。
  • 如果它是一个相对简单的项目,几乎没有外部依赖项,具有 VS 2017 和向上风格的 .csproj 格式,这很容易,只需在文本编辑器中打开您的 .csproj 文件并更改<TargetFramework>netcoreapp3.1(或任何您想要的 .NET Core 版本),但请确保您安装了正确的 SDK。如果它是“老派”风格的 csproj 格式,您首先需要对其进行转换(例如 this

标签: c# visual-studio .net-core .net-standard .net-framework-4.8


【解决方案1】:

正如 Roman Ryzhiy 在 cmets 中提到的,这是要走的路:

https://docs.microsoft.com/en-us/dotnet/core/porting/

这对我来说很好,我升级了 .NET Framework 4.7.2 项目。这是一个小项目,所以我几乎没有后遗症。升级后,Application 选项卡中的 Target Framework 会显示“.NET 5.0”。

  1. 安装升级助手:

    dotnet tool install -g upgrade-assistant

  2. 转到您的解决方案文件夹

  3. 运行助手:

    upgrade-assistant 升级 your-project-name.csproj

  4. 按照助手中的步骤进行操作,非常简单。

另外,这里是更详细的步骤:

https://docs.microsoft.com/en-us/dotnet/core/porting/upgrade-assistant-overview#installation-steps

【讨论】:

    猜你喜欢
    • 2021-10-03
    • 1970-01-01
    • 1970-01-01
    • 2017-08-05
    • 1970-01-01
    • 2020-01-23
    • 1970-01-01
    • 1970-01-01
    • 2018-05-01
    相关资源
    最近更新 更多