c# - Visual Studio 2019 v16.6无法构建.net5控制台应用程序并引发错误: . NETFramework,Version = v5.0未找到

标签 c# visual-studio .net-5

开发环境:

  • 已安装Visual Studio 2019 v16.6.2
  • .Net5预览版5已安装

  • Microsoft.NETCore.App 5.0.0-preview.5.20278.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]


  • 在Visual Studio中启用设计器
  • Tools > Options > Environment > Preview Features and select the Use the preview Windows Forms designer for .NET Core apps option. > re-start vs
    
    我按照此answer中的说明进行操作
    我在.net5中创建了一个演示控制台项目
    <Project Sdk="Microsoft.NET.Sdk">
    
      <PropertyGroup>
        <OutputType>Exe</OutputType>
        <TargetFramework>net5.0</TargetFramework>
      </PropertyGroup>  
    </Project>
    
    然后使用dotnet cli构建并运行就可以了
    dotnet build  #ok
    dotnet run # ok
    
    尝试在Visual Studio中构建项目失败并显示错误

    Error MSB3644 The reference assemblies for .NETFramework,Version=v5.0 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks


    Error NETSDK1005 Assets file 'F:\projects\Net5Demo\obj\project.assets.json' doesn't have a target for '.NETFramework,Version=v5.0'. Ensure that restore has run and that you have included 'net50' in the TargetFrameworks for your project.


    我错过了使用vs 2019 v16.6.2构建和运行项目的东西?

    最佳答案

    根据https://dotnet.microsoft.com/download/dotnet/5.0,您似乎还需要VS 2019 16.8预览版3才能识别它。
    编辑:我遇到了同样的问题,并且在我安装了VS 2019 16.8预览版3之后,它开始显示使用.NET 5.0的选项。

    关于c# - Visual Studio 2019 v16.6无法构建.net5控制台应用程序并引发错误: . NETFramework,Version = v5.0未找到,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62519231/

    相关文章:

    c# - ListBox 项目可以跨越多行吗? C#

    visual-studio - CMAKE : how to link executable to winmm imm32 version on windows with Visual Studio?

    visual-studio - 如何在 Visual Studio 中静态链接 VCPKG 生成的 .lib 文件

    javascript - CSS 和 JS 的 Visual Studio Code 比较(用于合并)

    c# - 在 .Net 5 应用程序中运行 SSIS

    c# - OWIN 不记名 token 认证

    c# - 如何获取本地 Windows 用户列表(仅限出现在 Windows 登录屏幕中的用户)

    c# - 在 c# 中从 Dataview 排序后选择前 N 行

    azure - Azure 应用服务中的 .NET5 Blazor 服务器应用返回 "You do not have permission to view this directory or page"

    azure - .NET 5 应用服务代码在 ARM 模板部署中被删除