azure-functions-host: dotnet publish fails with 'Metadata generation failed' sometimes

Repro steps

Provide the steps required to reproduce the problem:

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

Expected behavior

It should build without an error.

Actual behavior

OurFunctionApp -> C:\temp\bin\Release\netcoreapp2.1\bin\OurFunctionApp.dll
C:\Users\build-admin\.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]

Output of dotnet --version: 2.1.503

This error occurs sporadically on our Jenkins server. I can’t reproduce it on my computer. Also, I cannot reproduce it if run this command on the Jenkins server from command line prompt.

Can you help?

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 48 (18 by maintainers)

Most upvoted comments

The 1.0.28 update has broken my build with a new ‘Metadata generation failed’ (when running both locally and in VSTS). I simply reverted from 1.0.* to 1.0.27 because the older package still works fine.

However, I thought the bug report might be relevent here. The fix might be easy as you’ll notice the “binbin” extension and I suspect it has to do with the “_FunctionsExtensionsTasksDir”, but this is where my expertise ends.

Thanks for the great SDK

[...].nuget\packages\microsoft.azure.webjobs.script.extensionsmetadatagenerator\1.1.1\build\Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator.targets(33,5): error : Metadata generation failed. Exit code: '-532462766' Error: 'Error generating extension metadata: System.IO.DirectoryNotFoundException: The path '[...]\bin\Debug\netcoreapp2.1\binbin' does not exist. Unable to generate Azure Functions extensions metadata file.   at ExtensionsMetadataGenerator.ExtensionsMetadataGenerator.Generate(String sourcePath, String outputPath, ConsoleLogger logger) in C:\azure-webjobs-sdk-script\tools\ExtensionsMetadataGenerator\src\ExtensionsMetadataGenerator.Console\ExtensionsMetadataGenerator.cs:line 23   at ExtensionsMetadataGenerator.Console.Program.Main(String[] args) in C:\azure-webjobs-sdk-script\tools\ExtensionsMetadataGenerator\src\ExtensionsMetadataGenerator.Console\Program.cs:line 32Unhandled Exception: System.IO.DirectoryNotFoundException: The path '[...]\bin\Debug\netcoreapp2.1\binbin' does not exist. Unable to generate Azure Functions extensions metadata file.   at ExtensionsMetadataGenerator.ExtensionsMetadataGenerator.Generate(String sourcePath, String outputPath, ConsoleLogger logger) in C:\azure-webjobs-sdk-script\tools\ExtensionsMetadataGenerator\src\ExtensionsMetadataGenerator.Console\ExtensionsMetadataGenerator.cs:line 23   at ExtensionsMetadataGenerator.Console.Program.Main(String[] args) in C:\azure-webjobs-sdk-script\tools\ExtensionsMetadataGenerator\src\ExtensionsMetadataGenerator.Console\Program.cs:line 37```

I was able to get past the “binbin” issue by editing the Directory.Build.targets file in the function project.

I changed the line <_FunctionsExtensionsDir Condition=“$(_IsFunctionsSdkBuild) == ‘true’”>$(_FunctionsExtensionsDir)bin</_FunctionsExtensionsDir>

to remove the “bin”

<_FunctionsExtensionsDir Condition="$(_IsFunctionsSdkBuild) == 'true'">$(_FunctionsExtensionsDir)</_FunctionsExtensionsDir>

it looks like the $(TargetDir) variable already includes the “bin”, so having it here also doubles it up.

This was for an existing project. When I created a new project, the entire file is not there.

So then I tried deleting the Directory.Build.targets file, and that also seemed to work.

Hope that helps somebody 😉