简体   繁体   English

Visual Studio 目标框架灰显

[英]Visual Studio Target Framework Greyed out

I'm using Visual Studio 2019 v16.8.5 and this morning I found that my solution which targets .net5.0 could not build and had the error:我正在使用 Visual Studio 2019 v16.8.5,今天早上我发现我的针对 .net5.0 的解决方案无法构建并出现错误:

The TargetFramework value .net5.0-windows' was not recognized.无法识别 TargetFramework 值 .net5.0-windows'。 It may be misspelled.它可能拼写错误。 If not, then the TargetFrameworkIdentifier and/or TargetFrameworkVersion properties must be specified explicitly.如果不是,则必须明确指定 TargetFrameworkIdentifier 和/或 TargetFrameworkVersion 属性。

If I go into the project properties the Target Framework combobox is greyed out.如果我 go 进入项目属性,目标框架 combobox 将显示为灰色。 If I create a new solution, the combobox is still greyed out (however, the new solution targets .net3.1 and builds fine).如果我创建一个新的解决方案,combobox 仍然是灰色的(但是,新的解决方案针对 .net3.1 并且构建良好)。

I didn't have this problem yesterday and I haven't installed any updates.我昨天没有遇到这个问题,也没有安装任何更新。 I've also checked I don't have any global.json files in my solution as suggested in a similar post.我还检查了我的解决方案中没有任何 global.json 文件,如类似帖子中所建议的那样。

属性对话框

My property group is as follows:我的属性组如下:

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

  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net5.0-windows</TargetFramework>
    <UseWPF>true</UseWPF>

    <RootNamespace>Drain</RootNamespace>

    <ApplicationIcon>icon_vRx_icon.ico</ApplicationIcon>

    <Platforms>AnyCPU;x64</Platforms>

    <AssemblyVersion>0.0.0.1</AssemblyVersion>

    <FileVersion>0.0.0.1</FileVersion>

    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
  </PropertyGroup>

Any suggestions what might have happened?有什么建议可能发生了什么?

Sorry to reply you so late:抱歉这么晚才回复你:

Currently .Net 5.0 is not supported, it is recommended that you upgrade to .Net 6.0 as soon as possible.目前不支持.Net 5.0 ,建议您尽快升级到.Net 6.0

There is no problem in copying your property group under my 2019 16.11.13 version , you could try to update the version.在我的2019 16.11.13 version下复制你的属性组没有问题,你可以尝试更新版本。

I suggest you go to the visual studio installer to check whether the .Net 5.0 Runtime is installed correctly (you could try to reinstall).我建议你 go 到visual studio installer检查.Net 5.0 Runtime是否安装正确(你可以尝试重新安装)。

在此处输入图像描述

  • Finally, I want to ask, will you encounter the same problem when you create a new.Net 5.0 WPF project?最后想问一下,大家在新建.Net 5.0 WPF 项目时会遇到同样的问题吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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