The "NuGet.Build.Tasks.GetReferenceNearestTargetFrameworkTask" task could not be loaded

Justin 0 Reputation points
2023-01-16T08:40:12.9733333+00:00

Hello together,

I'm starting to despair. I get the error below on every project I try to build.

Severity Code Description Project File Line Suppression State

Error The "NuGet.Build.Tasks.GetReferenceNearestTargetFrameworkTask" task could not be loaded from the assembly C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\CommonExtensions\Microsoft\NuGet\NuGet.Build.Tasks.dll. Could not load file or assembly 'Microsoft.Build.Utilities.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The module was expected to contain an assembly manifest. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.

I have already tried any gacutil commands I have found the error and any other suggestions that have come up on google. Also, completely uninstalling via install clean-up from Visual Studio was unsuccessful.

Does anyone have any other ideas about what I could do?

Visual Studio 2022 version 17.4.4.

Thanks and kindly Regards

Justin

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,422 questions
Not Monitored
Not Monitored
Tag not monitored by Microsoft.
35,014 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Anna Xiu-MSFT 23,251 Reputation points Microsoft Vendor
    2023-01-17T05:09:11.1166667+00:00

    Hi @Justin, 

    Welcome to Microsoft Q&A!

    How did you build your project? 

    Please try to add the assembly into the global assembly cache:

    gacutil /i Microsoft.Build.Utilities.v4.0.dll 

    Meanwhile, please install the latest version of NuGet.Build.Tasks in package manager:

    NuGet\Install-Package NuGet.Build.Tasks -Version 6.4.0

    Sincerely,

    Anna


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". 
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments