Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nuget Package Restore not working- [closed]

I am trying to run the example C# code in visual studio for square connect:

https://github.com/square/connect-api-examples/tree/master/connect-examples/v2/csharp_payment

When I open the solution all of the references have a yellow triangle with and exclamation point next to them.

I have tried to restore nuget packages on the solution, uninstall and reinstall some and i can't get the triangles to go away. It won't build for me.

Any ideas? Thanks

like image 366
J DOE Avatar asked May 10 '17 23:05

J DOE


People also ask

How do I force a NuGet package to restore?

Restore NuGet packagesNavigate to Tools > Options > NuGet Package Manager > General, and then select the Allow NuGet to download missing packages check box under Package Restore. Enabling Restore NuGet Packages. In Solution Explorer, right-click the solution, and then select Restore NuGet Packages.

How do I fix a NuGet package error?

Quick solution for Visual Studio usersSelect the Tools > NuGet Package Manager > Package Manager Settings menu command. Set both options under Package Restore. Select OK. Build your project again.

What is the difference between NuGet restore and dotnet restore?

nuget restore will ensure all of your NuGet dependencies are downloaded and available to your project. Whereas dotnet restore is a complete restoration of all NuGet dependencies as well as references and project specific tools. Meaning that if you run nuget restore , you are only restoring NuGet packages.

Does Msbuild restore NuGet packages?

msbuild -t:Restore will restore nuget packages for projects with PackageReference nuget management format. And your situation looks like packages. config nuget management format which you have used it.


2 Answers

There is a target in their project file that can become problematic when projects are moved between systems.

You can fix the problem with two steps:

  1. Remove the entire <Target Name="EnsureNuGetPackageBuildImports" ..> element at the end of the project file, then reload the project.
  2. Execute an Update-Package -Reinstall in your (NuGet) Package Manager Console.

That should set everything right for your system and re-point to the correct versions of the relevant libraries.

like image 55
ladenedge Avatar answered Nov 09 '22 01:11

ladenedge


Try to delete packages folder at solution root and rebuild or restore packages again.

like image 31
Khoa Nguyen Avatar answered Nov 09 '22 00:11

Khoa Nguyen