Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NuGet Package restore failed for project myProjectWeb: Unable to find version '3.0.1' of package 'AppForSharePoint16WebToolkit'

It's a provider hosted project. It used to work until very recently.

If I create a completely new project/solution, then it works.

If I start the old one, or redownload it from source control, I get the following error:

NuGet Package restore failed for project LocalTheaterWeb: Unable to find version '3.0.1' of package 'AppForSharePoint16WebToolkit'

I tried Update-Package -Reinstall but the problem stays.

Any ideas?

like image 571
Demian Kasier Avatar asked Jun 19 '14 09:06

Demian Kasier


People also ask

How do I fix NuGet recovery failed?

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.

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 install NuGet packages missing?

Switch to the Browse tab, search for the package name, select it, then select Install). For all packages, delete the package folder, then run nuget install . For a single package, delete the package folder and use nuget install <id> to reinstall the same one.

How do I run a NuGet package restore in Visual Studio?

To do that, go to Tools, NuGet Packaged Manager, then go to Package Manager Settings. Go to the General section, and then make sure you have a checkmark for Allow NuGet to download missing packages and also to automatically check for missing packages during the build in Visual Studio.


2 Answers

The solution of Scott Hillier did it for me:

http://www.shillier.com/archive/2014/08/05/nuget-package-restore-fails-for-sharepoint-2013-provider-hosted-apps.aspx

I often take advantage of the NuGet Package Restore capability to reduce the size of my projects when saving or sharing them. Today, I discovered an issue with this process when building SharePoint 2013 Provider-Hosted Apps against SharePoint Online. Here are the steps to reproduce and the fix:

  1. Create a Provider-Hosted App in Visual Studio 2013 using a SharePoint Online site for debugging.
  2. Right click solution and "Enable NuGet Package Restore"
  3. Save and Close Project
  4. Delete the “packages” folder from project directory
  5. Open Project in Visual Studio 2013
  6. Rebuild, receive error “Unable to find AppForSharePoint16WebToolkit”
  7. Open Packages.config file
  8. Change “AppForSharePoint16WebToolkit” to “AppForSharePointWebToolkit”
  9. Rebuild – successfully this time. Apparently, the "AppForSharePoint16WebToolkit" package is not available through the NuGet Package Manager, but the older "AppForSharePointWebToolkit" package is available.
like image 60
Mathieu Avatar answered Nov 03 '22 00:11

Mathieu


The error message suggests that NuGet cannot find the AppForSharePoint16WebToolkit package in your package sources. So check the following:

  1. The correct package source is selected whilst doing the Update-Package -Reinstall.
  2. Check the package source that hosts the NuGet package is enabled. If you are using a recent version of NuGet the package restore should use all the enabled package sources.
  3. See if the solution or project has its own NuGet.config which is overriding the package sources.

Without further information my guess is 3. since you say it works for a new project.

You can also run Fiddler to see what package sources NuGet is using as it tries to restore.

like image 24
Matt Ward Avatar answered Nov 03 '22 00:11

Matt Ward