Azure Functions quit building with error after upgrading Visual Studio to 16.8.5

Aaron Peavy 6 Reputation points
2021-02-15T17:06:11.027+00:00

My Azure functions target x64 specifically due to some native dependencies. I have one that targets v1 (due to a Framework dependency) and one that is v3.
The error message is the same for both of them and only began on my local system after I upgraded to Visual Studio 16.8.5. Initially, the build would freeze indefinitely, but after clearing all nuget packages, it consistently gives an error now. None of my peers are seeing the problem on their machines.

Function v1 error:
.nuget\packages\microsoft.net.sdk.functions\1.0.38\build\Microsoft.NET.Sdk.Functions.Build.targets(44,5): error :
Error:
An assembly specified in the application dependencies manifest (Microsoft.NETCore.App.deps.json) was not found:
package: 'runtime.win-x64.Microsoft.NETCore.App', version: '2.1.25'
path: 'runtimes/win-x64/lib/netcoreapp2.1/System.ComponentModel.DataAnnotations.dll'
error : Metadata generation failed.

Function v3 error:
Metadata generation failed. Exit code: '-2147450740' Error: 'Error: An assembly specified in the application dependencies manifest (Microsoft.NETCore.App.deps.json) was not found: package: 'runtime.win-x64.Microsoft.NETCore.App', version: '2.1.25' path: 'runtimes/win-x64/lib/netcoreapp2.1/System.ComponentModel.DataAnnotations.dll''

Steps I have tried:

  1. Repair VS
  2. Update to preview version.
  3. Uninstall and reinstall 16.7
  4. Reset my repository
  5. Cleared all nuget packages

If I cannot solve this soon, my final resort will be a full system reset...

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,300 questions
Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,628 questions
Visual Studio Setup
Visual Studio Setup
Visual Studio: A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.Setup: The procedures involved in preparing a software program or application to operate within a computer or mobile device.
971 questions
Not Monitored
Not Monitored
Tag not monitored by Microsoft.
36,170 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Aaron Peavy 6 Reputation points
    2021-02-23T22:26:40.99+00:00

    After opening a ticket and discussing it with MS technical support, we were able to resolve this by uninstalling/reinstalling Net Core SDK 2.1. Why a function app that targets 3.1 would need 2.1 SDK installed at all is still a mystery, but my problem is solved.

    1 person found this answer helpful.
    0 comments No comments

  2. MayankBargali-MSFT 68,656 Reputation points
    2021-02-16T09:44:18.507+00:00

    Hi @Aaron Peavy

    Welcome to Microsoft Q&A! Thanks for posting the question.

    As per the error message looks like you are referencing the 2.1.25 of Microsoft.NETCore.App but this version was not found.
    An assembly specified in the application dependencies manifest (Microsoft.NETCore.App.deps.json) was not found:
    package: 'runtime.win-x64.Microsoft.NETCore.App', version: '2.1.25'
    path: 'runtimes/win-x64/lib/netcoreapp2.1/System.ComponentModel.DataAnnotations.dll'
    error : Metadata generation failed.

    Can you verify the version of System.ComponentModel.DataAnnotations referred in your project. Also, verify your .csproj file and see the PackageReference version for this.

    The suggestion would be to update the same version of System.ComponentModel.DataAnnotations that is referred to in your application dependencies.

    68622-image.png