【问题标题】:Azure functions - cannot be imported again. It was already imported at... (nuget, .net core 2.1) - a StackOverflow errorAzure 函数 - 无法再次导入。它已经在...(nuget,.net core 2.1)导入 - StackOverflow 错误
【发布时间】:2019-03-10 11:46:24
【问题描述】:

您好,

我有一个 .net core 2.1 网络应用程序。我在解决方案中添加了一个 Azure Function 应用。 我的函数应用引用了我的 Web 应用(因此我可以访问实体框架类)。
由于某种原因,我遇到了 Stack Overflow 错误。

如果我不引用网络应用程序,那么没有问题。

如果我引用一个新的 .netstandard 2 类库没有问题。

我正在使用 azure-functions-core-tools 2.4.419。

Warning 1

Severity    Code    Description Project File    Line    Suppression State
Warning MSB4011 "C:\Users\[myusername]\.nuget\packages\microsoft.azure.webjobs.script.extensionsmetadatagenerator\1.0.2\build\Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator.props" cannot be imported again. It was already imported at "C:\Code\Apps\Rubbish\WebAppWithFunctions\TestFunctionApp\obj\TestFunctionApp.csproj.nuget.g.props (17,5)". This is most likely a build authoring error. This subsequent import will be ignored. [C:\Code\Apps\Rubbish\WebAppWithFunctions\TestFunctionApp\TestFunctionApp.csproj] TestFunctionApp     38  

Warning 2

Severity    Code    Description Project File    Line    Suppression State
Warning MSB4011 "C:\Users\[username]\.nuget\packages\microsoft.azure.webjobs.script.extensionsmetadatagenerator\1.0.2\build\Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator.targets" cannot be imported again. It was already imported at "C:\Code\Apps\Rubbish\WebAppWithFunctions\TestFunctionApp\obj\TestFunctionApp.csproj.nuget.g.targets (9,5)". This is most likely a build authoring error. This subsequent import will be ignored. [C:\Code\Apps\Rubbish\WebAppWithFunctions\TestFunctionApp\TestFunctionApp.csproj]    TestFunctionApp     60  

Warning 3:
Severity    Code    Description Project File    Line    Suppression State
Warning         TestFunctionApp C:\Users\[username]\.nuget\packages\microsoft.azure.webjobs.script.extensionsmetadatagenerator\1.0.2\build\Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator.targets   20  

Warning 4:

Severity    Code    Description Project File    Line    Suppression State
Warning     Process is terminating due to StackOverflowException.   TestFunctionApp C:\Users\[username]\.nuget\packages\microsoft.azure.webjobs.script.extensionsmetadatagenerator\1.0.2\build\Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator.targets   20  

Error 1:

Severity    Code    Description Project File    Line    Suppression State
Error       Metadata generation failed. TestFunctionApp C:\Users\[username]\.nuget\packages\microsoft.azure.webjobs.script.extensionsmetadatagenerator\1.0.2\build\Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator.targets   20  

我的网络应用程序的 CSProj

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

  <PropertyGroup>
    <TargetFramework>netcoreapp2.1</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.App"  />
    <PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.1.2" PrivateAssets="All" />
  </ItemGroup>

</Project>

安装在网络应用上的 Nuget 包是:

Microsoft.AspNetCore.App 2.1.1
Microsoft.AspNetCore.Razor.Design 2.1.2
Microsoft.NETCore.App 2.1

提前致谢, 丹。

【问题讨论】:

  • 考虑将 EF 部分移出到单独的 .Net 标准程序集,并从 Web 应用程序和函数中引用它。
  • 完全同意这一点——这是我最初的计划,但我想知道为什么在我的生产应用程序中使用它之前会发生这种情况——我尝试了你在另一个应用程序中的建议,它运行良好。但我发现自己想知道为什么添加对 Web 应用程序的简单引用会破坏它。

标签: c# azure .net-core azure-functions stack-overflow


【解决方案1】:

以下是我在机器 VS 2017 中尝试过的相同配置。它对我有用

您能否检查一下您在 Azure 函数中使用的 SDK 是什么。对我来说,它正在使用 Microsoft.NetCore.App 2.2.0。

这是相同的屏幕截图。

尝试使用 Choco 命令升级你的 Azure 函数工具

choco upgrade azure-functions-core-tools

希望对你有帮助。

【讨论】:

  • 我的网络应用和功能是 2.1 而不是 2.2
猜你喜欢
  • 2018-02-08
  • 2014-09-14
  • 1970-01-01
  • 1970-01-01
  • 2021-07-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多