Restore Nuget Packages failing

Akkisetty Srinivasarao (WIPRO LIMITED) 0 Reputation points Microsoft External Staff
2024-12-12T06:29:02.07+00:00

I am unable to restore nuget packages. Getting below error :

User's image

Developer technologies | Visual Studio | Other
{count} votes

1 answer

Sort by: Most helpful
  1. Tianyu Sun-MSFT 34,441 Reputation points Microsoft External Staff
    2024-12-12T09:28:26.8066667+00:00

    Hello @Akkisetty Srinivasarao (WIPRO LIMITED) ,

    Welcome to Microsoft Q&A forum.

    Please try to set the <RestoreUseLegacyDependencyResolver> property to true in your project file(.xxproj file) and rebuild your project, restore the NuGet packages, see if this works.

    User's image

    If it doesn’t work, try to run this property in Developer Command Prompt for Visual Studio 2022.

    msbuild -t:restore -p:RestoreUseLegacyDependencyResolver="true".

    User's image

    I think the issue you got is caused by the changes in 6.12(NuGet), .NET 9 or 17.12(VS), kindly check this document: NuGet Dependency Resolver.

    In order to improve the performance and scalability of the restore operation, the restore algorithm was rewritten in the 6.12 release. As of the 6.12 release, the new restore algorithm is enabled by default for all PackageReference projects. While the new restore algorithm is functionally equivalent to the previous one, as with any software, bugs are possible. To revert to the previous implementation, set the MSBuild property RestoreUseLegacyDependencyResolver to true.

    I tested locally by manually installing one of the NuGet packages that shows in the screenshot that you shared, it is still possible to be downloaded and installed. So, if setting the above property doesn’t work, I think you can also try to check the package source and the limitations on your machine.

    About the package source, you can open Visual Studio, click Tools, NuGet Package Manager, Package Manager Settings, switch to Package Sources, make sure that the package sources are correctly set and there’s no invalid package source.

    User's image

    About the limitations, please check the antivirus software and the custom(if you created and modified it) nuget.config file.

    Kind Regards,

    Tianyu


    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.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.