gpt4 book ai didi

.net - 找不到匹配 : 'HttpTrigger' 的模板

转载 作者:行者123 更新时间:2023-12-02 22:50:00 28 4
gpt4 key购买 nike

我已经安装了Azure Functions Core Tools V.3.x来自微软。

我正在尝试遵循学习路径。到目前为止,它在处理节点时工作得很好。不管怎样,现在我正在尝试使用.net,所以我所做的如下:

func init

选择dotnet,它会在我的工作区中正常生成文件。下一步。

func new

并选择HttpTrigger,然后我收到此错误:

No templates found matching: 'HttpTrigger'.
To list installed templates, run 'dotnet new --list'.
To search for the templates on NuGet.org, run 'dotnet new HttpTrigger --search'.

因此,通过研究和阅读,我尝试遵循建议并最终使用此命令来安装模板:

dotnet new -i Microsoft.Azure.WebJobs.ItemTemplates

事实上,它已经确认我已经安装了HttpTrigger,如下图所示。但仍然存在与之前提到的相同的问题“未找到匹配的模板:'HttpTrigger'。”

我的问题是,在命令行中找不到模板的情况下出错的可能性是什么?

Note:

  • I have used cmd and PowerShell with administrator privileges as well.
  • When I try to create a project in Visual Studio 2019 it can create HttpTriggers without issues.
  • I have both Visual Studio 2019 and 2022 installed on Windows 10 environment.
  • This is the first time I use Azure Functions Core Tools and learned it.

enter image description here

最佳答案

Note: This solution applies for all other functions features that get the same issue with No templates found matching: etc....

对于那些在 HttpTrigger 或其他 Azure 函数功能方面面临类似问题的人。以下是问题的原因和解决方案以及我是如何解决的:

问题原因

安装不同的 SDK 版本会导致问题。

如何验证

所以运行这个命令

dotnet --list-sdks

这将显示已安装的 dotnet 版本,在我的例子中,dotnet 5dotnet 6 Preview 均已安装。

解决方案

所以我做了什么,我用了什么

dotnet 新的 globaljson

在我的项目/工作文件夹中,然后将 global.json 中的版本更新为 5,并且它有效😊。

关于.net - 找不到匹配 : 'HttpTrigger' 的模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68757838/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com