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?
Go to Tools -> Options -> NuGet Package Manager -> General -> Package Restore. The first option disables restore itself, while the 2nd option disables on build restore.
By Command-line: You can download nuget.exe,and add the path where it exists to Path system environment variables. Then you could simply reference the nuget.exe directly. After that you can use command like nuget update YourSolution. sln in Package Manager Console to update the dependencies for solution.
NuGet shared source packages A shared source package contains source code files that are included in a project when referenced. Because you're just including source code files that are compiled with the rest of your project, there's no external dependency and chance of conflict.
Dependency resolution with PackageReference. When installing packages into projects using the PackageReference format, NuGet adds references to a flat package graph in the appropriate file and resolves conflicts ahead of time. This process is referred to as transitive restore.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With