Allow the ability for a package to require a minimum version of NuGet


My team now has 5 packages on NuGet (yesterday we dropped another one, a preview to immutable collections) and by far our number one support question has been due to an older version of NuGet being installed. We take heavy advantage of the new portable and Windows Phone 8 lib folders (introduced in 2.1) – and attempting to install our packages to projects targeting those results in a very unhelpful error message:

Could not install package 'Microsoft.Bcl 1.0.0-alpha'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.0,Profile=Profile4', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

There are also cases where we want to take advantage of bug fixes (such as this: http://nuget.codeplex.com/workitem/2781) in later versions of NuGet that would result in unexpected behavior if those versions were not installed.

We’d like the ability for a package to require a specific version of NuGet to be installed so that we can reduce customer confusion and reduce our support cost.

Edited by dotnetjunky, copied from #2936

Presently, the client cannot detect what version of NuGet is needed until the package is downloaded and unzipped. We should store metadata on the server to indicate the client version required and display it and block installation if the client is not compatible. The client would fall back to current behavior if the server doesn't provide the NuGet version required for the package.
Closed Mar 11, 2013 at 8:11 AM by deepakverma
verified following test points:
- User is able  to find package is not supported with the current version and how to download the latest version
- minClientVersion from  (these are the package acquisition points)
    ○ package manager dialog
    ○ Powershell console
    ○ NuGet.exe
    ○ Template 
    ○ Gallery
    ○ Webmatrix (should just ignore the attribute)
- Transitive dependency package Package 1 has minversion as 2.3,  package2 has min version 2.4 . Package 1 depends on package2 do we error the user that 2.4 is the min version required.
- minClientVersion tests
    ○ Boundary value test
    ○ Negative tests
        § String
        § Null
        § 2.1.2 (hotfix)
        § Special character
- Back compat-
    ○ Try packages with minclientattribute  on Nuget 2.2


dotnetjunky wrote Dec 21, 2012 at 8:01 AM

I agree we should do this. The old clients of NuGet will not be able to recognize the new attributes though.

dotnetjunky wrote Jan 29, 2013 at 10:16 PM

Fixed. The new attribute is added as an attribute to the <metadata> element.

<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata __requiredMinVersion="2.3"__>


Please verify this is enforced both in VS and nuget.exe when installing and updating packages. This is not enforced when uninstalling packages.

dotnetjunky wrote Jan 29, 2013 at 10:17 PM

Duh, the markdown formatting is horrible.

danliu wrote Feb 21, 2013 at 7:48 PM

reassign to deepak as he's testing it.