Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I keep nuget from updating dependencies?

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?

like image 790
JeffreyABecker Avatar asked Jan 10 '12 20:01

JeffreyABecker


People also ask

How do I stop a NuGet package from restoring?

Go to Tools -> Options -> NuGet Package Manager -> General -> Package Restore. The first option disables restore itself, while the 2nd option disables on build restore.

How do I update NuGet dependencies?

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.

Are NuGet packages dependencies?

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.

What is transitive dependency NuGet?

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.


1 Answers

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.

like image 55
PHeiberg Avatar answered Oct 14 '22 11:10

PHeiberg