Uninstall package with NuGet–and remove dependencies

Posted by Marcus Hammarberg on February 28, 2011

Uninstall package with NuGet–and remove dependencies

With NuGet I almost long to add new stuff to my project – it’s a breeze and you almost forget the hustle of keeping track of what’s referenced and not.
One of the core features of NuGet is that it not only install the requested component, it also installs all the dependencies of the component – in the right versions. That list can be quite long. But what if you want to reverse the install?

With NuGet I almost long to add new stuff to my project – it’s a breeze and you almost forget the hustle of keeping track of what’s referenced and not.

One of the core features of NuGet is that it not only install the requested component, it also installs all the dependencies of the component – in the right versions. That list can be quite long. But what if you want to reverse the install?

As you can see – quite a lot of dependencies, one of the even added stuff to my web.config. But hey – I don’t care much. That’s NuGet’s problems nowadays. So all these components are pulled down, put into my packages folder (in the Solution root) and referenced in my project of choice.

But now I want to reverse that action. In this particular case I want to wait for an update of the OpenIdPortableArea package and use that. There is a simple uninstall package command. But what about the dependencies?

Again – it works just fine with the switch ‑RemoveDependencies So I simply go:

And my project is clean as a baby butt. Well I know from experience that that saying is not very well put – but it’s clean, let’s keep it to that. Everything is back to the state it was. The components are gone, the references as well and even any code changes that was made such as updating your web.config.

NuGet is just brilliant! It just works! Changed the way you looked on taking dependencies on OSS projects.