Getting "Metadata generation failed" when building C# function app in Visual Studio 2019

Solution 1:

To solve this issue, upgraded Microsoft.NET.Sdk.Functions to last version(3.0.1).And delete the netstandard1.0 folder:

"C:\Users\myname\.nuget\packages\microsoft.net.sdk.functions\1.0.29\build\netstandard1.0

Solution 2:

This error started occurring for me when I upgraded the "Microsoft.NET.Sdk.Functions" to 4.0.0 or above (unfortunately). Staying with 3.0.13 allows it to compile without error.