Using NuGet 1.5+ with Existing Project which Has a Package with an Invalid ID

Sep 8, 2011 at 9:26 PM

I know that's a long title, but it pretty well sums up our problem.  For some background, see this previous thread:  The gist of it is:

 We have been using NuGet packages to manage our internal shared libraries since the first betas were available. However, we started with an invalid package ID (spaces in the name).

We were able to work around the upgrade problem for now, but with NuGet 1.5, we have a new problem: Any project that has a previous version of the package—not of the libraries; that version has not changed—no longer works with NuGet.  For example, installing the Entity Framework package generates this result:

Successfully installed 'EntityFramework 4.1.10715.0'.
Install failed. Rolling back...
The package ID 'MyOrganization Stack Library' contains invalid characters. Examples of valid package IDs include 'MyPackage' and 'MyPackage.Sample'.

While we do want to make sure that our current library packages conform to the NuGet spec, does anyone have suggestions on the least-painless way to ensure that a few dozen teams who already have the "older" package installed in their solutions can continue to use NuGet after upgrading to 1.5?

Sep 8, 2011 at 11:35 PM

Ack! Unfortunately, I think you’ll have to uninstall those packages and then install the new ones. You might be able to write a PS script that does this for you and send it around.


Jan 5, 2012 at 6:36 PM

With the latest NuGet packages, there is no way to uninstall packages with invalid IDs using the Package Manage Console or the Package Manage GUI. Any attempted action causes the same error: "The package ID 'MyOrganization Stack Library' contains invalid characters. Examples of valid package IDs include 'MyPackage' and 'MyPackage.Sample'."

All of the current versions of our libraries use the correct format for IDs, but there is no easy way for the (very many) projects which referenced the old NuGet package to update to the new, improved, and corrected package—or work with any other NuGet features.

(The workaround has been to manually remove the reference to the package from packages.config, but that does not enable a clean update, since NuGet thinks it's a new install rather than an update.)