45

I'm trying to give the SignalR Sample a test drive but it seems it references an old version of SignalR which is no longer available. The actual problem is that NuGet cannot remove the unavailable package without first restoring it !!!

PM> Install-Package Microsoft.AspNet.SignalR
Install-Package : Some NuGet packages are missing from the solution. The packages need to be restored in order to build the dependency graph. Restore the packages before performing any operations.
At line:1 char:1
+ Install-Package Microsoft.AspNet.SignalR
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Install-Package], InvalidOperationException
    + FullyQualifiedErrorId : NuGetMissingPackages,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Then there will be a Restore button on the Package Manager Console which pressing it will result in the following error:

An error occurred while trying to restore packages: Unable to find version '2.1.0-pre-131116-b279' of package 'Microsoft.AspNet.SignalR.Client'

How can I install a newer version of an addressed package if the current version can not be found?

I'm using:

Microsoft Visual Studio Community 2015
Version 14.0.24720.00 Update 1
Microsoft .NET Framework
Version 4.6.01038
NuGet Package Manager   3.3.0

[UPDATE]

When I try to uninstall the troublesome package:

PM> Uninstall-Package -Id Microsfot.AspNet.SignalR -RemoveDependencies -Force
Uninstall-Package : Some NuGet packages are missing from the solution. The packages need to be restored in order to build the dependency graph. Restore the packages before performing any operations.
At line:1 char:1
+ Uninstall-Package -Id Microsfot.AspNet.SignalR -RemoveDependencies -F ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Uninstall-Package], InvalidOperationException
    + FullyQualifiedErrorId : NuGetMissingPackages,NuGet.PackageManagement.PowerShellCmdlets.UninstallPackageCommand
Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
Mehran
  • 15,593
  • 27
  • 122
  • 221

5 Answers5

39

You can manually remove the dependency by:

  1. Close Visual Studio (not a hard requirement, but helpful)
  2. In text editor, remove dependency from all packages.config files
  3. Remove package from packages/ directory
  4. In text editor, remove all references to package from all .csproj files
  5. Start Visual Studio
  6. Reinstall package through NuGet
Myster
  • 17,704
  • 13
  • 64
  • 93
Joe Hawkins
  • 9,803
  • 2
  • 21
  • 28
  • Thanks but there's no `packages.json`, there's only `packages.config` and it's in XML format. – Mehran Dec 08 '15 at 06:17
  • 17
    Upvoted as it works... but this is insane! Surely there must be an easier path to handling this if a NuGet package is no longer available? – Holf Apr 07 '17 at 13:59
  • 1
    You can do this in Visual Studio. There is no reason to close it. Just delete the reference, remove the package line from the packages (config or json) file. Then refresh Nuget, and install the version you want. – phokus Apr 25 '18 at 21:44
  • @JoeHawkins we don't have any way to force nuget to update packages to the latest? – Hieu Le Aug 09 '18 at 03:06
  • @hiule I don't know. haven't been in the .Net game for nearly three years. Your best Google is as good as mine. – Joe Hawkins Aug 09 '18 at 03:16
  • Crazy that this is the only solution! – David Harlow Oct 17 '19 at 14:10
15

There's an easier solution, if you know the versions that currently exist in the feed. This solution can fix every package in every project.

  • Open packages.config file (if you have more than one project, do this for every packages.config file)
  • Update versions to the correct ones (i.e. change the version attribute)
  • In the Package Manager Console, type Update-Package -Reinstall

Hope it helps

ferarias
  • 333
  • 2
  • 11
  • 3
    This did not work for me, Update-Package just spewed "Some NuGet packages are missing from the solution. The packages need to be restored in order to build the dependency gr aph. Restore the packages before performing any operations.". That's a nice catch-22 they got going there. – Søren Boisen Jul 02 '17 at 22:42
  • 1
    Did you try updating your NuGet.exe version? Try nuget.exe update -Self – ferarias Jul 11 '17 at 11:34
  • 2
    Yea this is much easier than the accepted answer. I did that once I swore to never do it again, alas. Never say never, but this makes it much easier, especially with a solutions with hundreds of projects. +1 (But it re-installs EVERYTHING) – Piotr Kula Sep 06 '17 at 13:27
  • I agree with @ppumkin. It might take a while, but it does the job – Emiel Koning May 23 '18 at 10:41
  • @ppumkin You don't have to have it reinstall everything. If you add the -id parameter with the package name then it will just do that one package. – Wayne Koorts Jan 08 '19 at 03:05
2

What works for me is:

1. Go to the packages.config file,

2. Find "... id="Microsoft.AspNet.SignalR.Client" version="" targetFramework="net45"..."

3. Change to an existing version, say "2.2.0".

4. Save.

5. Go to Nuget, and update to the latest.

Yh Zheng
  • 31
  • 2
1

Mentioned by @ferarias in a comment - if you are using nuget.exe, try updating it or downloading the latest version.

For me, upgrading from v4.4.1 to v4.6.2 was enough to fix the Some NuGet packages are missing error.

Dunc
  • 18,404
  • 6
  • 86
  • 103
1

In my case, I'd restarted visual studio. Then I'd removed nuget package entry from package.config.

After that I was able to restore the dependency.

arif.khan.b
  • 311
  • 3
  • 8