azure - dotnet 发布有时失败并显示 'Metadata generation failed'

标签 azure .net-core azure-functions

我们有一个 Azure 函数应用程序。运行时版本为 2。有时此命令在我们的构建服务器上失败(Jenkins 在 Windows Server 上运行):

dotnet publish C:\temp\OurFunctionApp.csproj -c Release -o C:\temp\output

错误:

C:\Users\user1.nuget\packages\microsoft.azure.webjobs.script.extensionsmetadatagenerator\1.0.1\build\Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator.targets(20,5): error : Metadata generation failed. [C:\temp\OurFunctionApp.csproj]

当我从命令行运行此命令时,它总是工作正常。

我们的构建服务器上没有安装 Visual Studio。

如何诊断并修复此错误?

.csproj 文件:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netcoreapp2.1</TargetFramework>
    <AzureFunctionsVersion>v2</AzureFunctionsVersion>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.ApplicationInsights" Version="2.8.1" />
    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.EventHubs" Version="3.0.1" />
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.24" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\Project1\Project1.csproj" />
    <ProjectReference Include="..\Project2\Project2.csproj" />
    <ProjectReference Include="..\Project3\Project3.csproj" />
    <ProjectReference Include="..\Project4\Project4.csproj" />
  </ItemGroup>
  <ItemGroup>
    <None Update="ourlist.txt">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </None>
    <None Update="host.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
    <None Update="local.settings.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <CopyToPublishDirectory>Never</CopyToPublishDirectory>
    </None>
  </ItemGroup>
</Project>

最佳答案

我在使用 Net Framework 4.7 时也遇到同样的问题。

要解决此问题,您应该更新 Microsoft.NET.Sdk.Functions nuget 包。

关于azure - dotnet 发布有时失败并显示 'Metadata generation failed',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54660616/

相关文章:

azure - 如何在不依赖注入(inject)的情况下配置 TelemetryConfiguration?

linq - 如何在 Entity Framework Core 中按周分组?

azure - Azure Functions 中的个人 One Drive Microsoft Graph 绑定(bind)

Azure媒体服务获取缩略图文件URL

azure - 使用门户更改 Azure 应用程序设置,无需重新启动

c# - Azure Functions System.Net.Primitives : Value cannot be null.(参数 'host' )

c# - 启用 ASP.Net Core session 锁定?

reactjs - 通过 Azure Function 和 auth0 进行存储帐户应用程序身份验证

node.js - 我们如何将消息从特定事件中心分区获取到 azure 函数中,以及如何自动扩展 azure 函数的数量?

javascript - 在 yaml 中的 gulp 任务中设置 --max_old_space_size