简体   繁体   English

Visual Studio 中的 Azure Function 样板代码找不到命名空间

[英]Azure Function boilerplate code from visual studio cannot find namespaces

I am trying to create an Azure Function project in Visual Studio 2019. I go through all the prompts and the project is created.我正在尝试在 Visual Studio 2019 中创建 Azure Function 项目。我通过所有提示创建 go 并创建项目。 However, when I switch to the code file, I see that there are red squiggly lines all over.但是,当我切换到代码文件时,我看到到处都是红色的波浪线。 It seems the project cannot find any of the dependencies.该项目似乎找不到任何依赖项。

I try adding the dependencies via right clicking on the suggestions which I see adds them in the csproj file and in the dependencies section in the solution explorer.我尝试通过右键单击我看到将它们添加到 csproj 文件和解决方案资源管理器的依赖项部分中的建议来添加依赖项。 But that does not fix the issue.但这并不能解决问题。

Running dotnet restore completes successfully, but does not solve the issue.运行dotnet restore成功完成,但未解决问题。 I still have the red lines saying that the namespaces cannot be found and the yellow triangle on all of my dependencies.我仍然有红线表示找不到命名空间,并且我的所有依赖项上都有黄色三角形。

I believe this has to be an issue with my environment since I have not actually written any code yet.我相信这一定是我的环境的问题,因为我实际上还没有编写任何代码。 I believe I have all the SDKs installed to build azure functions with .NET core.我相信我已经安装了所有的 SDK 来构建具有 .NET 核心的 azure 功能。 This is using .NET Core 2.1.这是使用 .NET Core 2.1。

Thanks!谢谢!

UPDATE - I tried opening an Azure Functions project from another group and I was able to build and run the project.更新 - 我尝试打开另一个组的 Azure Functions 项目,我能够构建和运行该项目。 I tried comparing the.csproj files but nothing was obvious as to why I would not be able to find any dependencies.我尝试比较 .csproj 文件,但对于我找不到任何依赖项的原因没有什么明显的。 The only difference was that in my.csproj file, there were many more Package References which I had added via NuGet.唯一的区别是在 my.csproj 文件中,我通过 NuGet 添加了更多的 Package 参考。 The only common package reference was Microsoft.NET.Sdk.Functions唯一常见的 package 参考是Microsoft.NET.Sdk.Functions

I found the answer by creating a new Azure Function project in a different folder.我通过在不同的文件夹中创建一个新的 Azure Function 项目找到了答案。 When I created the new project in a different folder, it worked without an issue.当我在不同的文件夹中创建新项目时,它可以正常工作。 Then I tried renaming the folder that I wanted to use and that fixed the issue.然后我尝试重命名我想使用的文件夹并解决了这个问题。 The folder name had a URL encoded space (%20).文件夹名称有一个 URL 编码空间 (%20)。 When I changed the %20 to a '-', that resolved the issue.当我将 %20 更改为“-”时,问题就解决了。

The folder name had the '%20' in the name because when I cloned the repo, I did not change the default folder name which had a '%20' because there is a space in the repository name and had to be encoded in the clone url.文件夹名称的名称中包含“%20”,因为当我克隆存储库时,我没有更改具有“%20”的默认文件夹名称,因为存储库名称中有一个空格并且必须在克隆 url。

Also, I do not know why that solved the issue.另外,我不知道为什么这解决了这个问题。

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

相关问题 无法使用 Visual Studio 2017 调试 Azure 函数 - Cannot debug Azure Function with Visual Studio 2017 将Azure功能从门户导入Visual Studio - Import Azure Function from portal into Visual Studio 在Visual Studio Mac中找不到命名空间Microsoft.Azure - Cannot find namespace Microsoft.Azure in Visual Studio Mac Visual Studio:无法从代码访问资源 - Visual Studio: cannot access resources from code 无法在Azure门户中查看通过Visual Studio创建/部署的功能的代码,但是当我通过门户进行功能创建时可以 - Cannot view code in Azure portal for function created / deployed via Visual Studio, yet I can when I make the function via the portal 从 Visual Studio 发布代码时如何将文件上传到 Azure 函数? - How do I upload file to Azure function while publishing the code from Visual Studio? Visual Studio中的命名空间在哪里 - Where are the namespaces in visual studio Visual Studio和名称空间 - Visual Studio and namespaces Azure 应用服务无法从 visual studio 2019 发布 - Azure App service cannot publish from visual studio 2019 如何在Visual Studio解决方案中找到所有名称空间? - How do I find all namespaces in my Visual Studio solution?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM