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?
in the package manager console and NuGet went:
'MvcContrib' not installed. Attempting to retrieve dependency from source... Done. 'MicrosoftWebMvc (≥ 2.0)' not installed. Attempting to retrieve dependency from source... Done. 'Mvc2Futures (≥ 2.0.50217.0)' not installed. Attempting to retrieve dependency from source... Done. 'DotNetOpenAuth' not installed. Attempting to retrieve dependency from source... Done. Successfully installed 'Mvc2Futures 2.0.50217.0'. Successfully installed 'MicrosoftWebMvc 2.0'. Successfully installed 'MvcContrib 188.8.131.52'. Successfully installed 'DotNetOpenAuth 184.108.40.20657'. Successfully installed 'OpenIdPortableArea 220.127.116.11'. Successfully added 'Mvc2Futures 2.0.50217.0' to Web. Successfully added 'MicrosoftWebMvc 2.0' to Web. Successfully added 'MvcContrib 18.104.22.168' to Web. Successfully added 'DotNetOpenAuth 22.214.171.12457' to Web. Successfully added 'OpenIdPortableArea 126.96.36.199' to Web.
(Please note the AutoComplete feature by hitting tab; command names, parameters and even remote package name. Start typing (in my case)
OpenId, hit TAB and make your choice).
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:
Uninstall-Package OpenIdPortableArea –RemoveDependencies
and NuGet does this:
Successfully removed 'OpenIdPortableArea 188.8.131.52' from Web. Successfully removed 'DotNetOpenAuth 184.108.40.20657' from Web. Successfully removed 'MvcContrib 220.127.116.11' from Web. Successfully removed 'MicrosoftWebMvc 2.0' from Web. Successfully removed 'Mvc2Futures 2.0.50217.0' from Web. Successfully uninstalled 'OpenIdPortableArea 18.104.22.168'. Successfully uninstalled 'DotNetOpenAuth 22.214.171.12457'. Successfully uninstalled 'MvcContrib 126.96.36.199'. Successfully uninstalled 'MicrosoftWebMvc 2.0'. Successfully uninstalled 'Mvc2Futures 2.0.50217.0'.
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.
Published byon Last updated