不能将.NET Core 5.0应用程序与Visual Studio Community 2019版本16.7.5一起使用

问题描述

一周前,我想使用.NET Core 5.0。我已经在PC上安装了它:

enter image description here

我使用dotnet命令创建了一些应用程序。运行良好。我什至可以启动使用.NET Core 5.0创建的每个应用程序。 当我使用Visual Studio创建.NET Core应用程序时,问题就开始了。

enter image description here

解决方案资源管理器充满警告信号:

enter image description here

const ids = ['5trgh','5njkn'] const options = [{ text: 'A',_id: '5trgh' },{ text: 'B',_id: '5vjds' },{ text: 'C',_id: '5njkn' }]; const filterarry = options.filter(item => ids.includes(item._id)); console.log(filterarry)文件显示我使用的是.NET Core 5.0版本:

ConsoleApp1.csproj

我还没有更改应用程序。 <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <TargetFramework>net5.0</TargetFramework> </PropertyGroup> </Project>

Program.cs:

我决定为自己的应用选择using System; namespace ConsoleApp1 { class Program { static void Main(string[] args) { Console.WriteLine("Hello World!"); } } } 。我去了项目设置,发现没有选择我的标记框架。我想选择一个,但是只有Target Framework个目标框架:

enter image description here

我试图在Enternet上观看答案。这就是为什么我在以下位置检查.NET Framework

enter image description here

它仍然不起作用。它不适用于新旧项目。也许现在没有机会使用Visual Studio调试Use previews of the .NET Core SDK (requires restart)

解决方法

要使用.NET Core 5.0,应单独下载Visual Studio的preview version(从此处:https://visualstudio.microsoft.com/vs/preview/)。 如果您已经安装了.NET Core 5.0 SDK,但不知道如何将项目中的.NET Core版本切换回早期版本,请在您的项目中编写netcoreapp3.1(也许是其他版本)而不是net5.0。 .csproj个文件。例如我的ConsoleApp1.csproj

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp3.1</TargetFramework>
  </PropertyGroup>

</Project>

感谢@Ian Kemp