简体   繁体   English

Visual Studio 无法定位 .NET 框架 4.8

[英]Visual Studio Can't Target .NET Framework 4.8

I'm having some issues creating a project that targets .NET Framework 4.8.我在创建一个针对 .NET Framework 4.8 的项目时遇到了一些问题。 I am using Visual Studio 2019, upgraded to version 16.2.5.我正在使用升级到版本 16.2.5 的 Visual Studio 2019。 I have also installed the .NET Framework 4.8 Developer Pack .我还安装了.NET Framework 4.8 Developer Pack From the Visual Studio Installer, I don't see any option for enabling 4.8 development tools similar to 4.7 .从 Visual Studio 安装程序中,我看不到任何启用类似于 4.7的 4.8 开发工具的选项。

Just had a similar issue with Visual Studio 2019 Community Edition: only.Net Core versions were shown.刚刚在 Visual Studio 2019 社区版中遇到了类似的问题:仅显示了 .Net Core 版本。

I edited the .csproj file manually.我手动编辑了.csproj文件。 I changed the line with the TargetFramework property to我将具有TargetFramework属性的行更改为

<TargetFramework>net48</TargetFramework>

Oddly, now all other versions show up also.奇怪的是,现在所有其他版本也出现了。

Just thought I'll post my issues as I stumbled across this too with VS2019 Winforms project, and couldn't target anything apart from.Net 5 and Core 3.1.只是想我会发布我的问题,因为我在 VS2019 Winforms 项目中也偶然发现了这个问题,并且除了.Net 5 和 Core 3.1 之外无法定位任何东西。 Turns out there're 2 types of Winforms, Winforms App and Winforms App (.Net Framework).原来有两种类型的 Winforms,Winforms App 和 Winforms App (.Net Framework)。 The former won't be able to target the other .net framework.前者将无法针对其他 .net 框架。 The latter is able to.后者是可以的。 Duh.呃。 Simple stuffs that aren't obvious.不明显的简单东西。

This Visual Studio thread had all the answers I was looking for.这个Visual Studio 线程有我正在寻找的所有答案。 The .NET Framework 4.8 Developer Pack includes both the SDK and Targeting Pack..NET 框架 4.8 开发包包括 SDK 和目标包。 After installing this and restarting Visual Studio, I can now see .NET Framework 4.8 as a targeting option for Visual Studio projects.安装此工具并重新启动 Visual Studio 后,我现在可以看到 .NET Framework 4.8 作为 Visual Studio 项目的目标选项。 You should not need to do any Visual Studio Installer steps.您不需要执行任何 Visual Studio 安装程序步骤。

Also mentioned in the above thread, .NET Framework 4.8 will be included in the Visual Studio installation process as of 16.3 ( currently listed under 16.3 Preview 2 ).在上述线程中还提到,.NET Framework 4.8 将包含在 Visual Studio 安装过程中,从 16.3 开始( 目前在 16.3 Preview 2 下列出)。

None of the solutions above fixed my issues but the one by Oak_3260548 Pointed me in the right direction.上述解决方案都没有解决我的问题,但 Oak_3260548 的解决方案为我指明了正确的方向。

In Visual Studio Installer, that can be accessed by clicking on " Tools / Get Tools and features " in the top menu, I selected the " Individual Component " tab and checked " .Net Framework 4.8 Targeting pack ".在 Visual Studio 安装程序中,可以通过单击顶部菜单中的“工具/获取工具和功能”来访问,我选择了“单个组件”选项卡并选中了“ .Net Framework 4.8 目标包”。 That fixed it for me.那为我修好了。 在此处输入图像描述

I installed framework 4.8 through VS under target frameworks.我在目标框架下通过 VS 安装了框架 4.8。 It wasn't selectable there, under project properties as I would expect.正如我所期望的那样,在项目属性下无法选择它。

I wound up having to re-create my VS project.我最终不得不重新创建我的 VS 项目。 For template, I found framework 4.8 through searching templates in project creation using framework c# console search params.对于模板,我通过使用框架 c# 控制台搜索参数在项目创建中搜索模板找到了框架 4.8。 I then copied my files over to the new project folder, and added them as existing items through the solution tool.然后我将我的文件复制到新的项目文件夹中,并通过解决方案工具将它们添加为现有项目。

For anybody having this issue in VS 2019 Community edition.对于在 VS 2019 社区版中遇到此问题的任何人。 The problem in my case was confusion over which template to select.在我的案例中,问题是混淆了 select 的模板。 Templates for .NET Framework are in parenthesis and lower in the list (not showing at all in my case until I clicked the "clear" link next to the search box). .NET 框架的模板在括号中并且在列表的较低位置(在我单击搜索框旁边的“清除”链接之前,在我的情况下根本不显示)。

Examples:例子:

Console App (.NET Framework) ASP.NET Web Application (.NET Framework) Class Library (.NET Framework) etc控制台应用程序 (.NET Framework) ASP.NET Web 应用程序 (.NET Framework) Class 库 (.NET Framework) 等

I have found a solution: If I want Visual Studio Community 2019 to target .NET 4.8, I can create some simple projects by using Visual Studio Express 2013. In the Project settings I change the required .NET (up to 4.8) and save.我找到了一个解决方案:如果我希望 Visual Studio Community 2019 以 .NET 4.8 为目标,我可以使用 Visual Studio Express 2013 创建一些简单的项目。在项目设置中,我更改所需的 .NET(最高 4.8)并保存。 After that, you can open that project with Visual Studio Community 2019 and you will see in the Project settings all .NET target options up to 4.8.之后,您可以使用 Visual Studio Community 2019 打开该项目,您将在项目设置中看到所有 .NET 目标选项高达 4.8。

However, if you want to play with .NET Core 3.1 and .NET 5.0, you have to create a new project from within Visual Studio Community 2019.但是,如果您想使用 .NET Core 3.1 和 .NET 5.0,您必须在 Visual Studio Community 2019 中创建一个新项目。

No solution above solved my problem.上面没有解决我的问题。 The note in https://docs.microsoft.com/en-us/visualstudio/ide/step-1-create-a-windows-forms-application-project?view=vs-2019 point 2 note helped: https://docs.microsoft.com/en-us/visualstudio/ide/step-1-create-a-windows-forms-application-project?view=vs-2019第 2 点注释中的注释帮助:

Note笔记

If you don't see the Windows Forms App (.NET Framework) template, you can install it from the Create a new project window.如果您没有看到 Windows Forms App (.NET Framework) 模板,您可以从创建新项目 window 安装它。 In the Not finding what you're looking for?在未找到您要查找的内容? message, choose the Install more tools and features link.消息,选择安装更多工具和功能链接。

The 'Install more tools and features' link from the 'Not finding what you're looking for' message in the 'Create new project' window “创建新项目”window 中的“未找到您要查找的内容”消息中的“安装更多工具和功能”链接

在此处输入图像描述

Next, in the Visual Studio Installer, choose the .NET desktop development workload.接下来,在 Visual Studio 安装程序中,选择.NET 桌面开发工作负载。

在此处输入图像描述

After that, choose the Modify button in the Visual Studio Installer.之后,选择 Visual Studio 安装程序中的修改按钮。 You might be prompted to save your work;系统可能会提示您保存工作; if so, do so.如果是这样,请这样做。 Next, choose Continue to install the workload.接下来,选择继续安装工作负载。

Although I always check this when installing VS it was missing.虽然我在安装 VS 时总是检查它,但它丢失了。 And the tepmlates were missing even though I had the correct trageting packs installed.即使我安装了正确的跟踪包,也缺少 tepmlates。

C:\Program Files\Microsoft Visual Studio\2022\Community\Msbuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets C:\Program Files\Microsoft Visual Studio\2022\Community\Msbuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets

<!--
<GetReferenceAssemblyPaths
    Condition="'$(TargetFrameworkMoniker)' != '' and ('$(_TargetFrameworkDirectories)' == '' or '$(_FullFrameworkReferenceAssemblyPaths)' == '')"
    TargetFrameworkMoniker="$(TargetFrameworkMoniker)"
    RootPath="$(TargetFrameworkRootPath)"
    TargetFrameworkFallbackSearchPaths="$(TargetFrameworkFallbackSearchPaths)"
    BypassFrameworkInstallChecks="$(BypassFrameworkInstallChecks)"
    >
  <Output TaskParameter="ReferenceAssemblyPaths" PropertyName="_TargetFrameworkDirectories"/>
  <Output TaskParameter="FullFrameworkReferenceAssemblyPaths" PropertyName="_FullFrameworkReferenceAssemblyPaths"/>
  <Output TaskParameter="TargetFrameworkMonikerDisplayName" PropertyName="TargetFrameworkMonikerDisplayName" Condition="'$(TargetFrameworkMonikerDisplayName)' == ''"/>
</GetReferenceAssemblyPaths>
-->

1. Choose WPF APP (.NET Fromework) with XMAL 1.使用XMAL选择WPF APP(.NET Fromework)

2. Select .NET 4.8 2. Select .NET 4.8

On Visual Studio 2022, I choose the WPF APP (.NET Fromework) with XMAL can support .NET Framework在 Visual Studio 2022 上,我选择带有 XMAL 的 WPF APP (.NET Fromework) 可以支持 .NET 框架

Even with lower Visual studio (mine is 15.2 under Win 2008 R2), you can do it!即使使用较低的 Visual Studio(我的是 Win 2008 R2 下的 15.2),您也可以做到!

  1. Install both Net Framework 4.8 Runtime AND Developper Pack安装 Net Framework 4.8 Runtime 和 Developper Pack
  2. Reboot the server重启服务器
  3. Open your existing project and in the project properties, switch the framework to 4.8打开现有项目并在项目属性中,将框架切换到 4.8

That's it!而已!

enter image description here What happens when I get prompted在此处输入图像描述当我收到提示时会发生什么

every time I click continue, it doesn't seem to install or allow me to go forward, it visibly shows that my files are unloaded.每次我单击继续时,它似乎都没有安装或允许我向前 go,它明显表明我的文件已卸载。 Am I doing something wrong?难道我做错了什么?

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

相关问题 .Net Framework 4.8 未显示在 Visual Studio 目标框架下拉列表中 - .Net Framework 4.8 not showing up in Visual Studio Target Framework dropdown Visual Studio 2019 - 将 .NET 目标框架更改为 4.8 - Visual Studio 2019 - change .NET target framework to 4.8 Visual Studio Community 2017无法定位.net Framework 4.0,未在目标页面上列出 - Visual Studio Community 2017 can't target .net framework 4.0, not listed on target page 如何在 Windows 10 上的 Visual Studio 2017 中卸载 .NET Framework 4.8? - How to uninstall .NET Framework 4.8 in Visual Studio 2017 on Windows 10? 缺少 Visual Studio 2013 发布先决条件对话框 .NET 框架 4.8 - Visual Studio 2013 publish prerequisites dialog is missing .NET Framework 4.8 .NET Framework 4.8 已安装但未在 Visual Studio 2019 社区中显示 - .NET Framework 4.8 is installed but not showing in Visual Studio 2019 community 我可以使用Visual Studio 2015来定位.net框架4.7吗? - Can I use Visual Studio 2015 to target .net framework 4.7? .net 5 在 Visual Studio 16.8 中不能用作目标框架 - .net 5 not available as Target Framework in Visual Studio 16.8 在Visual Studio 2017中选择.NET Target Framework - Selecting .NET Target Framework in Visual Studio 2017 为什么我无法卸载 .NET Framework 4.8? - Why can't I uninstall .NET Framework 4.8?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM