Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dotnet publish fails with 'Metadata generation failed' sometimes

We have an Azure function app. Runtime version is 2. Occasionally this command fails on our build server (Jenkins running on Windows Server):

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

The error:

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]

When I run this command from command line it always works fine.

We don't have Visual Studio installed on our build server.

How to diagnose and fix this error?

.csproj file:

<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>
like image 417
Pavel Chuchuva Avatar asked Feb 13 '19 00:02

Pavel Chuchuva


2 Answers

I have the same issue with Net Framework 4.7.

To solve the problem you should update Microsoft.NET.Sdk.Functions nuget package.

like image 54
zolty13 Avatar answered Sep 28 '22 06:09

zolty13


In order to avoid the same issue, i have created a Windows accounts (Admin) by DevOps Agent.

The goal of that is to have for each account it's own folder for nugets. (No more // issues on the same folder) C:\Users\Agent1.nuget C:\Users\Agent2.nuget ...

Since i have change all Windows service with the new windows account i have no more errors in my builds ;) (need to restart the Agent Windows Service)

like image 30
didaskein Avatar answered Sep 28 '22 08:09

didaskein