简体   繁体   中英

Can't use .NET Core 5.0 application with Visual Studio Community 2019 Version 16.7.5

A week ago I wanted to use .NET Core 5.0. I have installed it on my PC:

在此处输入图像描述

I used do.net commands to create some applications. It worked well. I can even launch every application I have created with .NET Core 5.0. Problems start when I create .NET Core Application with Visual Studio.

在此处输入图像描述

The solution explorer is full of warning signs:

在此处输入图像描述

ConsoleApp1.csproj file shows me that I use .NET Core 5.0 version as it should be:

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

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net5.0</TargetFramework>
  </PropertyGroup>

</Project>

I didn't change the applications yet. Program.cs:

using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
        }
    }
}

I decided that I should choose the Target Framework for my application. I went to the project settings and saw that my taget framework wasn't selected. I wanted to choose one but there is only .NET Framework target frameworks:

在此处输入图像描述

I tried to watch answers on the ente.net. That is why I checked Use previews of the .NET Core SDK (requires restart) on:

在此处输入图像描述

It still doesn't work. It doesn't work with old or new projects. Maybe there is no chance to Debug .NET Core 5.0 with Visual Studio now?

To use .NET Core 5.0 you should download the preview version of the visual studio separately (from here: https://visualstudio.microsoft.com/vs/preview/ ). If you have already installed .NET Core 5.0 SDK and don't know how to switch back version of the .NET Core in your project to an earlier one, then write.netcoreapp3.1 (maybe another version) instead of.net5.0 in your .csproj file. For example my ConsoleApp1.csproj :

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

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

</Project>

Thanks to @Ian Kemp

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM