Anton Kutishevsky
Anton Kutishevsky

Reputation: 188

"Could not restore packages" in Visual Studio code when opening a project

After each update of MacOS or Visual Studio any project I open throws this error and can't restore packages. It happens in Visual Studio for Mac, the latest version.

Screenshot of the package console

1

Once I had a similar issue when a vpm connection was active, after disabling it Visual Studio had no issues with packages. But this time I don't have any VPN enabled.

Upvotes: 1

Views: 3951

Answers (2)

Anton Kutishevsky
Anton Kutishevsky

Reputation: 188

For those who is interested, I found a solution to this issue.

  1. Execute this command in terminal for the project dotnet nuget locals --clear all
  2. While the project(solution) is opened in the Visual Studio, double-click on the top file (Solution) > Build > General > check the Build with MSBuild on Mono option.

Upvotes: 2

BrianWithAY
BrianWithAY

Reputation: 23

Microsoft suggests the following if restore is not working:

  1. Select the Tools > NuGet Package Manager > Package Manager Settings menu command.
  2. Set both options under Package Restore.
  3. Select OK.
  4. Build your project again.

https://learn.microsoft.com/en-us/nuget/consume-packages/package-restore-troubleshooting

Another suggestion:

Try deleting the project.assets.json file in the obj folder of your project and then right click on the solution and click Restore NuGet Packages again.

https://developercommunity.visualstudio.com/t/restore-nuget-packages-is-not-working/1367227

If those don't work here are other overflow suggestions: NuGet Package Restore Not Working

Hope this helps!

Upvotes: 1

Related Questions