Skip to content

How to fix ‘error: metadata-generation-failed’?

  • by
  • 2 min read

Programming has come a long way since the early Assembly days. However, as easy as coding is today, programmers can still run into random bugs and errors from time to time.

In this article, we’re talking about how to fix the ‘error: metadata-generation-failed’ problem in C#.

Also read: How to fix ‘Exec user process caused: Exec format error’?


Upgrade .NET SDK

One of the main causes of this error is your Microsoft.NET.Sdk.Functions package is outdated. Update the package to the latest version and then delete the netstandard1.0 folder located at the path given below. 

C:\Users\[username]\.nuget\packages\microsoft.net.sdk.functions\1.0.29\build\netstandard1.0

Check your function names

If your code references two or more function apps with the same function name in the FunctionNameAttribute property, changing the names of the functions so they have unique attributes can fix the problem.

What is Metadata? Types and benefits | Candid.Technology
Photo by Shahadat Shemul

Also read: How to fix ‘error: failed building wheel for Wordcloud’?


Clean Git branch and rebuild

Sometimes the error can get triggered because of too many untracked files in the Git branch. Cleaning the branch and rebuilding the code can fix this problem. You can use the following command to clean your branch.

git clean -xdf

Do keep in mind that the command will clean the branch of all untracked files, so make sure to save your files and commit any important changes first. Once you’re done, clean the previous build’s output and rebuild the program.


Reinstall Visual Studio Code with .NET Core components

Another cause of the error is the .NET Core 3.1 (LTS Runtime) component missing from Visual Studio Code. To fix this, you will have to completely uninstall VS Code and any components and extensions you’ve installed.

Once the uninstall is complete, reinstall VS Code and this time, make sure that the .NET Core 3.1 (LTS Runtime) component is enabled during installation. Try rebuilding your code once you’re certain and the installation is complete. 

Also read: How to fix ‘Clang: Error: No input files’?

Yadullah Abidi

Yadullah Abidi

Yadullah is a Computer Science graduate who writes/edits/shoots/codes all things cybersecurity, gaming, and tech hardware. When he's not, he streams himself racing virtual cars. He's been writing and reporting on tech and cybersecurity with websites like Candid.Technology and MakeUseOf since 2018. You can contact him here: yadullahabidi@pm.me.

>