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?
For example the other day I wanted to include OpenIdPortableArea in my ASP.NET MVC application. It’s just a simple NuGet away. I went:
Install-Package OpenIdPortableAreain the package manager console and NuGet went:
'MvcContrib' not installed. Attempting to retrieve dependency from source...(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).
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 2.0.95.0'.
Successfully installed 'DotNetOpenAuth 3.4.6.10357'.
Successfully installed 'OpenIdPortableArea 1.0.0.3'.
Successfully added 'Mvc2Futures 2.0.50217.0' to Web.
Successfully added 'MicrosoftWebMvc 2.0' to Web.
Successfully added 'MvcContrib 2.0.95.0' to Web.
Successfully added 'DotNetOpenAuth 3.4.6.10357' to Web.
Successfully added 'OpenIdPortableArea 1.0.0.3' to Web.
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 –RemoveDependenciesand NuGet does this:
Successfully removed 'OpenIdPortableArea 1.0.0.3' from Web.And my project is clean as a baby... 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.
Successfully removed 'DotNetOpenAuth 3.4.6.10357' from Web.
Successfully removed 'MvcContrib 2.0.95.0' from Web.
Successfully removed 'MicrosoftWebMvc 2.0' from Web.
Successfully removed 'Mvc2Futures 2.0.50217.0' from Web.
Successfully uninstalled 'OpenIdPortableArea 1.0.0.3'.
Successfully uninstalled 'DotNetOpenAuth 3.4.6.10357'.
Successfully uninstalled 'MvcContrib 2.0.95.0'.
Successfully uninstalled 'MicrosoftWebMvc 2.0'.
Successfully uninstalled 'Mvc2Futures 2.0.50217.0'.
NuGet is just brilliant! It just works! Changed the way you looked on taking dependencies on OSS projects.
1 comment:
Tack för tipset om Uninstall och dependencies! Hade detta problem häromdagen.
Post a Comment