How can I keep nuget from updating dependencies?

5.1k Views Asked by At

I'm attempting to install a nuget package which has incorrectly specified one of it's dependencies. Common.Logging.Log4Net requires log4net = 1.2.10 however the nuget package specifies log4net >= 1.2.10. Even if I manually install the older version of log4net, nuget upgrades log4net to 1.2.11 when I install Common.Logging.Log4Net. How can I get nuget to bypass dependency resolution or at least prefer installed packages of a sufficient version?

1

There are 1 best solutions below

0
On BEST ANSWER

In order to bypass dependency resolution you can use the -IgnoreDependencies option:

Install-Package -IgnoreDependencies ThePackageName

You should be able to lock the package to a specific version by hand-editing the packages.config and setting the allowedVersions attribute to indicate the version span you want to allow.

<package id="Common.Logging.Log4Net" version="1.2.10" 
     allowedVersions="[1.2,1.2.10]" />

Note that his will however not upgrade the version of the package at all even when explicitly updating the package.

See the nuget versioning documentation for more info on versioning.