Dependency Only Cannot Mix Dependencies Warning

Topics: General
Oct 1, 2012 at 6:11 PM

After upgrading to version 2.1 of NuGet from version 2.0, I have started to notice the following warning when running the NuGet Command Line.

"Child dependencies of dependency only packages cannot mix external and project packages."

This is causing not all packages in our solution to be updated.  Running the update command for a second time seems to make this warnings disappear and successfully update all packages in a solution.

I have started to debug into the NuGet source code and got to a method in PackageWalker.cs (Project Core -> PackageWalker) called ProcessPackageTarget.  I can follow what is happening mostly until hitting where the exception is thrown.  

if (parentInfo.Target == PackageTargets.All) {
throw new InvalidOperationException(NuGetResources.DependencyOnlyCannotMixDependencies);
}

Digging further into it I notice the possible enums for PackageTargets are:

None = 0,        Project = 1,        External = 2,        All = Project | External

I have no idea what these enums are and was hoping someone could explain this warning.  The comment for this conditional statement also isn't exactly clear.  This warning did not happen with version 2.0, but since upgrading to 2.1 it causing us to run update twice on all of our solutions.  As a result, this takes almost twice as long for our NuGet updates locally and on the build system.

Oct 8, 2012 at 4:13 PM

I'm experiencing this error too. I didn't think I even have any "dependency only packages". Further, I don't know what an external vs a project package is.

Basically the error makes absolutely no sense to me, and it prevents me from upgrading packages without using the -IgnoreDependencies flag.

Can someone explain what this validation is meant to accomplish? The message itself provides no context or recourse for correcting the purported problem.

Oct 9, 2012 at 6:38 PM

We did a bad job of picking the term 'external package'. It really means solution-level package, meaning a package that doesn't have any assemblies or content files. When NuGet installs such a package, it doesn't install it into a project, but installs it into the solution.

A dependency only package is a package that doesn't contain any assembly or content files. It only has dependencies on other packages.

Oct 9, 2012 at 7:02 PM

It seems to me that something is causing packages to be installed/restored, but not be unzipped, which later causes an update to fail because it thinks a package is "external" or "dependency only" when it is not. If I go manually unzip all nupkg files in my packages folder, the behavior changes. I'll keep seeing if I can figure out what's going on.