Monday, October 15, 2012

Forcing a NuGet Package to update

By default NuGet skips updating a package when there is no higher version number. This brought us into trouble because we changed a package without updating the version number(only the file version had changed). So all our developers had to remove and re-install the package.

Until NuGet 2.1 there was no way to force an update regardless. NuGet 2.1 addresses this with the ‘reinstall’ flag.

Let’s have a look at the sample from the NuGet 2.1 release notes:

Previous versions of NuGet would result in the following when attempting to update a package that did not have a more recent package version:

PM> Update-Package Moq

No updates available for 'Moq' in project 'MySolution.MyConsole'.

With the reinstall flag, the package will be updated regardless of whether there is a newer version.

PM> Update-Package Moq -Reinstall

Successfully removed 'Moq 4.0.10827' from MySolution.MyConsole.

Successfully uninstalled 'Moq 4.0.10827'.

Successfully installed 'Moq 4.0.10827'.

Successfully added 'Moq 4.0.10827' to MySolution.MyConsole.


Renaud Bompuis said...

That little bit about -Reintall was certainly a most useful trick. Saved me aftger making a mess of deleting /obj and /bin folders in my projects and not realizing that some nuget package data was installed there.
Thanks for the tip.

Vcom Infotech Company said...

The details for the NuGet which is very much useful to know. Thank you very much. ecommerce solution provider in coimbatore | coimbatore ecommerce

Designpluz said...

It is a great sharing me...I am very much pleased with the contents you have mentioned. I wanted to thank you for this great article. I enjoyed every little bit part of it.Web Design Sydney