Update Nuget packages – after converting framework

NuGet 2.1 offers a feature that makes this a lot simpler: just do update-package -reinstall -ignoreDependencies from the Package Manager Console.

NuGet 2.0 doesn’t handle re-targeting your applications very well. In order to change your packages’ target frameworks, you must uninstall and reinstall the packages (taking note of the packages you had installed so that you can reinstall each of them).

The reason packages must be uninstalled and reinstalled is:

When installing a package, we determine the target framework of your project
We then match that up with the package contents, finding the appropriate \lib\ folder (and \content\ folder)
Assembly references are added with Hint Paths that point to the package’s \lib\ folder, with the right subfolder (\lib\net40 for example)
Content files are copied from the packages \content\ folder, with the right subfolder (\content\net40 for example)
We record the targetFramework used to install the package within the packages.config file
After you change your project’s target framework, the Hint Paths still point to net40
When you uninstall packages, we check the targetFramework that was recorded in packages.config to see what target framework’s libs/content to remove from your project
When you reinstall the package, we detect your updated target framework and reference/copy the right libs/content

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s