Enable package restore does not remove old packages

Topics: General
Feb 25, 2013 at 7:02 PM
Edited Feb 25, 2013 at 7:02 PM
We use NuGet packages extensively in a large team solution (>90 projects). We enabled the package restore option Lately we noticed a weird behavior from NuGet: packages we updated remains listed as installed (in both the dialog and the console) event though they are not used anymore. The only way to get rid of these packages is to manually clean the /packages folder.

Here's an output of what I'm getting when running the get-package command on my machine after one of my colleague updated a few packages this morning:

Id Version


I'm not expecting to see duplicated packages. When I inspect the older packages from the Manage NuGet Packages dialog I see that none of them are marked as installed in a project. Why are they listed as installed if they are not used?

First, I would expect NuGet not to list a package as installed when it is not referenced from a packages.config file anymore. Does it makes sense?

Second, why doesn't the restore package process remove the old package (if it is not used anymore) when restoring the newer package during the build process?

Feb 26, 2013 at 5:34 PM
I suspect the old packages are still being used in one of the project. Have you check with all 90+ projects? If you select an old package version, and look at the right details pane, it will show you what projects are currently using that package.
Feb 27, 2013 at 5:32 PM

The Manage NuGet Packages dialog shows that the old library is not installed in any project. The same dialog confirm the newer version is installed in the projects where it should be,

I think my problem is the same as described this Work Item: http://nuget.codeplex.com/workitem/1982. I'm glad to see it is part of the next release :)

Feb 27, 2013 at 7:55 PM
Can you install the latest build and see if it has fixed your issue? http://build.nuget.org/Nuget.Tools.vsix
Mar 1, 2013 at 4:35 PM
Edited Mar 1, 2013 at 4:36 PM
I installed the latest build this morning. I tried this build on a smaller solution. Here's what I did (after installing the update) and the behavior I got:
  1. Get the latest source for the solution (I knew one of my colleague updated a NuGet reference from XYZ.Common.13.1.13052.1 to XYZ.Common.13.1.13050.2 in that solution) and my local package folder only contained XYZ.Common.13.1.13052.1
    2, NuGet downloaded the newer version during the build process
  2. The /packages now contains both version of the package
  3. In the Manage Package dialog, the Xyz.Common package is listed only once (great!) and it can be updated to a newer version from this dialog
  4. When running the "Update-Package Xyz.Common" command in the PM Console I get this error:
    -> Update-Package : 'Xyz.Commun' was not installed in any project. Update failed.
So, this version does bring some improvement, but I think there's still some work to do to make the whole process smoother.


PS I noticed another strange behavior: after I updated the Xyz.Commun package to a newer version using the dialog the /packages folder + the repositories.config file were included in the pending changes as added files. I always thought that folder and it's content should not be stored in the source control. Why does VS want to add these files to SC?
Mar 14, 2013 at 3:03 PM
Update: I realize today that the Package Manager Console shows multiple versions of the packages when using the Get-Packag command. Thus we have inconsistent behavior between the dialog and the console in this version.

I wish we can have the same behavior for both the dialog and the console in the next release :)
Mar 14, 2013 at 4:49 PM
That's the correct and intended behavior. In the Console, the Get-Package command shows all packages installed in the solution, not just packages installed in the current project.

The console and the dialog will not have the same behavior. The console is meant for advanced usage, so it will offer extra options that are not in the dialog.
Mar 14, 2013 at 5:15 PM
Let me explain the issue with the Console more in details.

  • Only one version of the package is installed in the solution
  • Some older version of the package exists in the /packages solution (but they are not installed in any of the projects)
  • I'm running NuGet Extension 2.3.40228.73
1- Dialog: Shows only the latest package as installed (that's correct)
2- Console: Shows all packages in the /packages folder as installed when running Get-Package (that's not correct)
3- I cannot run a Update-Package command for that package in the Console as it give me an error saying that "Package is not installed in any project" (it looks for the older package).

From my point of view, the Dialog and the Console should have the same behavior for that scenario. I'm I correct?