在 Visual Studio 2019 中找不到 .NET 5.0 Console App 项目模板 [英] Cannot find .NET 5.0 Console App project template in Visual Studio 2019

查看:48
本文介绍了在 Visual Studio 2019 中找不到 .NET 5.0 Console App 项目模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试在 Visual Studio 2019 中创建 C# .NET 5.0 控制台应用程序,但该选项没有像我预期的那样出现在项目模板下.

我下载了 Visual Studio Professional 2019 版本 16.9.4(来自 和


  • 选项 2: Install via Visual Studio Installer 像这样..
<块引用>

您可以使用修复 VS 安装缺少的工作负载(这也将更新安装程序),并确保检查您选择的可选包想要使用 VS 安装程序工具,请参阅


安装程序启动后,检查是否为桌面和控制台选择了 .NET Core 工作负载......如下所示......在右侧窗格中,您需要选中正确的框

清除 Visual Studio 组件缓存(& 可选的所有模板)

现在,如果您已经按照上述步骤操作,请确认您选中了.net-Desktop development"复选框.在 Visual Studio 安装程序中是否选择了右上角:删除缓存并恢复

即您可以在 VS2017/2019 中恢复模板然后再试一次.

<块引用>

杀死开发进程首先运行这个Get-Process devenv |Foreach-Object { $_.CloseMainWindow() |Out-Null }

请参考以下步骤:

  1. DELETE ItemTemplatesCacheProjectTemplatesCache 文件夹 Ent.教授.C:Program Files (x86)Microsoft Visual Studio2019EnterpriseCommon7IDE. &C:UsersAppDataLocalMicrosoftVisualStudio16.0_93de0ddd
  2. 在命令提示符中,导航到 devenv.exe 的位置.此文件位于 Common7IDE 中.
  3. 键入/运行此命令 devenv/installvstemplates 并按 Enter.

仅供参考 - 你的模板缓存 在这里,包含以模板文件夹中存档中的 zip 文件命名的文件夹.您将需要管理员权限进行编辑/删除.

//模板缓存微软

<块引用>

 %AppData%MicrosoftVisualStudio{some_version}ItemTemplatesCache

//用于验证、修复/重新安装或删除的模板路径

<块引用>

 %USERPROFILE%DocumentsVisual Studio 2019TemplatesProjectTemplates

<块引用>

 %USERPROFILE%DocumentsVisual Studio 2019TemplatesItemTemplates

<块引用>

 %ProgramFiles(x86)%Microsoft Visual Studio2019<版本>Common7IDEItemTemplates

<块引用>

 %ProgramFiles(x86)%Microsoft Visual Studio2019<版本>Common7IDEProjectTemplates


选项 3: 调试您的环境.模板配置文件夹

检查/诊断版本:

<块引用>

运行这个dotnet --version安装正确的核心版本https://dotnet.microsoft.com/download/dotnet/5.0 更多此处这个 dotnet new -u 会告诉你安装了哪些模板,你可以卸载、清除包缓存、重新启动并使用修复工具重新安装.

下载并运行 collect.exe - https://aka.ms/vscollect - 并在 github

仅供参考 - 这就是您在 Visual Studio 中的模板文件夹结构的样子.

└───我的模板│ 控制台.cs│ 自述文件.txt│└───.template.config模板文件


I'm currently trying to create a C# .NET 5.0 Console Application in Visual Studio 2019, and the option does not appear under project templates as I expect it to.

I downloaded Visual Studio Professional 2019 Version 16.9.4 (from https://visualstudio.microsoft.com/downloads/) and selected all workloads to be installed, then I installed SDK 5.0.202, ASP.NET Core Runtime 5.0.5, .NET Desktop Runtime 5.0.5, and .NET Runtime 5.0.5 (from https://dotnet.microsoft.com/download/dotnet/5.0).

When I go to File -> New -> Project and search for "Console Application", there is no default "Console Application" project template for C#. The closest I can find is "Console Application (.NET Framework)" for C#, VB, and F# and "Console Application" for C++. If I select "Console Application (.NET Framework)" for C#, the latest Framework that I can choose is ".NET Framework 4.8".

Actual Outcome: Project Templates

Actual Outcome: Frameworks

I compared notes with a developer who did not run into this problem, and they see the same framework restriction when they select "Console Application (.NET Framework)" for C#, but is also able to see the project template "Console Application" for C# (without ".NET Framework") and select ".NET 5.0 (Current)" as the target framework as expected. Nothing about what they installed and updated appeared to be noticeably different, our results for the command prompt command "dotnet --info" matched, and they did not have any "Installed products" listed under "About" or "Individual Components" listed under the installer that I was missing.

Expected Outcome: Project Templates

Expected Outcome: Frameworks

I have tried uninstalling and reinstalling everything, exhaustively installing every workload as well as additional individual components that looked potentially relevant, and making sure that the "Tools -> Options -> Environment -> Preview Features -> Show All .NET Core templates in the New project dialog (requires restart)" checkbox is checked.

Does anyone know what step I'm missing that is preventing me from creating a Console Application project template in C# using .NET 5.0?

解决方案

Background -- This change/broke, issue that Microsoft opted deliberately you can read more here and the issue reported here but you can fix this with the 2 options listed below, i.e. A) enable it OR B) add it to VS via the repair tool

suggest clear VStudio Cache's -- kill dev process & clear cache before re/starting VS

run this cmd as admin in powershell

Get-Process devenv | Foreach-Object { $_.CloseMainWindow() | Out-Null }

Then DELETE ItemTemplatesCache, ProjectTemplatesCache folder ent. prof. etc.. C:Program Files (x86)Microsoft Visual Studio2019EnterpriseCommon7IDE.


Now please Proceed with these Steps/Options


  • Option 1: you may have to enable this option...

Tools > Options > Preview Features > "Show all .NET Core templates in the New project dialog (requires restart)".


  • Option 2: Install via Visual Studio Installer like so..

You can install missing workloads using the repair VS (this will also update the installer) and make sure you check the optional packages you want from the VS Installer tool please see this


after the installer starts check if the .NET Core workload is selected for desktop and console.. like below.. on the right pane you will need to check the correct boxes

Clear Visual Studio Component Cache (& optionally all Your templates)

Now, if you have already followed the above steps, then verifying you selected the checkbox of ".net-Desktop development" on top right is selected or not on Visual Studio installer: delete the cache and restore

i.e. you could restore the template in VS2017/2019 then try it again.

Kill dev process first run this Get-Process devenv | Foreach-Object { $_.CloseMainWindow() | Out-Null }

Please refer to the following steps:

  1. DELETE the ItemTemplatesCache, ProjectTemplatesCache folder Ent. or Prof. version etc.. C:Program Files (x86)Microsoft Visual Studio2019EnterpriseCommon7IDE. & C:Users<USERNAME>AppDataLocalMicrosoftVisualStudio16.0_93de0ddd
  2. In the command prompt, navigate to the location of devenv.exe. This file is located in Common7IDE.
  3. Type/Run this command devenv /installvstemplates and press Enter.

FYI - your templates cache is here, containing folders named after the zip files from your archives in the template folder. you will need admin privilege's for edits/delete.

//templates cache Microsoft

 %AppData%MicrosoftVisualStudio{some_version}ItemTemplatesCache

//templates path for verification, repair/reinstall or delete

 %USERPROFILE%DocumentsVisual Studio 2019TemplatesProjectTemplates

 %USERPROFILE%DocumentsVisual Studio 2019TemplatesItemTemplates

 %ProgramFiles(x86)%Microsoft Visual Studio2019<edition>Common7IDEItemTemplates

 %ProgramFiles(x86)%Microsoft Visual Studio2019<edition>Common7IDEProjectTemplates


Option 3: debugging your env. Template Config folder

Checking/Diagnosing the version:

run this dotnet --version install the correct core version https://dotnet.microsoft.com/download/dotnet/5.0 more here this dotnet new -u will tell you which templates are installed, you can uninstall, clear the packages cache, restart and reinstall with the repair tool.

Download and run collect.exe - https://aka.ms/vscollect - and share the log file created in %TEMP%vslogs.zip with MS on github

FYI - This is what your template folder structure in visual studio should look like.

└───mytemplate
    │   console.cs
    │   readme.txt
    │
    └───.template.config
            template.json


这篇关于在 Visual Studio 2019 中找不到 .NET 5.0 Console App 项目模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆