Nuget not using "lowest satisfying version"

Apr 19, 2012 at 6:55 PM
Edited Apr 19, 2012 at 6:56 PM

I created my own package containing some utility functions, call it Foo.Common.Core. It has a packages.config file with one line

<package id="log4net" version="1.2.10" allowedVersions="[1.2,)" />

I want to be able to use this with log4net 1.2.10 (and beyond) because some sites I'm working on have other dependencies that lock log4net down to =1.2.10.

Now I open my project, BarSite where I want to install Foo.Common.Core.

I check its packages.config and find

<package id="log4net" version="1.2.10" />

 so when I run install-package Foo.Common.Core, why does it fail with this:

PM> install-package Foo.Common.Core
Attempting to resolve dependency 'log4net (>= 1.2)'.
Successfully installed 'log4net 1.2.11'.
Successfully installed 'Foo.Common.Core 1.0.4492.23014'.
Install failed. Rolling back...
Install-Package : Updating 'log4net 1.2.10' to 'log4net 1.2.11' failed. Unable to find versions of 'N2CMS, N2CMS.Library that are compatible with 'log4net 1.2.11'.

So it's reading the dependency correctly -- 1.2 or above, but not accepting the 1.2.10 that's already installed-- why?

Apr 19, 2012 at 7:02 PM

I've also tried locking it to [1.2.10,). Still tries to install 1.2.11. If I specify [1.2.10] then it works but I don't want to be restricted like that. 

Partly I blame log4net for really mucking things up between 1.2.10 and 1.2.11 :)

Apr 19, 2012 at 8:54 PM

I'm confused. What do you mean when you say the package has packages.config file? A package can't contain packages.config. Only project does.

Apr 19, 2012 at 8:57 PM

The project that I'm using to create the package for Foo.Common.Core has a packages.config. I have a .nuspec file created from the project file, and when I run nuget at command line to pack the project I see 

Using 'Foo.Common.Core.nuspec' for metadata.
Found packages.config. Using packages listed as dependencies
Successfully created package 'C:\code\...\Foo.Common.Core.1.0.4492.23014.nupkg'.

Apr 19, 2012 at 9:02 PM

I see. So after you get the package, you try to install it on another project?

We have a known bug in which when you install the package Foo.Common.Core into a project that already has a dependency package, we try to update the dependency package to the latest version that still satisfies the conditions, even if the existing version already does satisfy those.

 

Apr 19, 2012 at 9:07 PM

 install-package Foo.Common.Core
Attempting to resolve dependency 'log4net (>= 1.2)'.
Successfully installed 'log4net 1.2.11'.
Successfully installed 'Foo.Common.Core 1.0.4492.23014'.
Successfully added 'log4net 1.2.11' to MvcApplication1.
Successfully added 'Foo.Common.Core 1.0.4492.23014' to MvcApplication1.

This is in a new, blank, MVC3 application with no packages. Package search order is official nuget feed, then my in-house server.