How to force Nuget not to update log4net to 1.2.11

That’s a quick one. There’s been a new release of log4net recently that’s signed with a new key, and therefore is incompatible with old version 1.2.10.

Therefore, due to near-ubiquity of the library in .NET space, it may cause some problems if you happen to have a dependency (direct or indirect) on it.

The matters are made worse by Nuget’s default of getting the latest available version of the package. I dealt with this problem the other day, and I saw a few people in my twitter stream struggling with the same issue.

The solution is quite simple. It’s not specific to log4net and I’m not picking on log4net here. Here’s how you can restrict Nuget’s package to specific version in your solution.

 

So imagine you install a package that has a dependency on log4net. In this case, the dependency is specified as specifically version 1.2.10 (as opposed to Nuget’s default: this version of newer).

nuget_core

If after that we install another package that also depends on log4net but doesn’t restrict the version, we’ll have a problem.

nuget_log4net_fail

The package we were trying to install doesn’t get installed. Actually, even if it did, we would have a problem since it most likely was compiled against log4net 1.2.10 anyway, and if Nuget updated log4net to version 1.2.11 the app would throw an exception at runtime due to mismatched assembly.

So there is a solution to restrict version of the package to specific version (in this case 1.2.10) as specified in the documentation.

nuget_log4net_fail_solution

After adding allowedVersions=”[1.2.10]” we can try again and this time the package will install properly.

nuget_log4net_fail_avoided

Notice it says it installed log4net 1.2.11. I checked my packages folder, and project dependencies and the version referenced was 1.2.10 so all is good.

Hope that helps


Posted 01-31-2012 1:28 PM by Krzysztof Koźmic
Filed under:

[Advertisement]

Comments

Leon van Bokhorst wrote re: How to force Nuget not to update log4net to 1.2.11
on 01-31-2012 8:51 AM

Thanks a lot. This is a lifesaver for me.

Søren wrote re: How to force Nuget not to update log4net to 1.2.11
on 02-05-2012 12:14 PM

What if I actually would like to use log4net 1.2.11 ?? Do I then need to recompile Castle?

Krzysztof Kozmic wrote re: How to force Nuget not to update log4net to 1.2.11
on 02-05-2012 10:25 PM

@Søren

Castle is built against log4net 1.2.10 and since 1.2.10 and 1.2.11 are not compatible yes, you would need a built of Castle log4net integration compiled against log4net 1.2.11

Neeraj wrote re: How to force Nuget not to update log4net to 1.2.11
on 11-01-2012 5:42 PM

Hi Dominick,First of all, I want to say i've been a big fan of your work, especially WIF topcis. Reading your blog is the first thing i've been doing every moring the past 2 months. With the release of this Thinktecture.IdentityModel.40, i'm wondering if there is any plan to update the IdentityServer (.Net 4 version) to make use of this library and also offer support JWT from the OAuth2 endpoint? I've started to do the conversion and making to changes to the IdentityServer source code but i'm not 100% confident on whether i've done it correctly.Thanks,Ryan N

About The CodeBetter.Com Blog Network
CodeBetter.Com FAQ

Our Mission

Advertisers should contact Brendan

Subscribe
Google Reader or Homepage

del.icio.us CodeBetter.com Latest Items
Add to My Yahoo!
Subscribe with Bloglines
Subscribe in NewsGator Online
Subscribe with myFeedster
Add to My AOL
Furl CodeBetter.com Latest Items
Subscribe in Rojo

Member Projects
DimeCasts.Net - Derik Whittaker

Friends of Devlicio.us
Red-Gate Tools For SQL and .NET

NDepend

SlickEdit
 
SmartInspect .NET Logging
NGEDIT: ViEmu and Codekana
LiteAccounting.Com
DevExpress
Fixx
NHibernate Profiler
Unfuddle
Balsamiq Mockups
Scrumy
JetBrains - ReSharper
Umbraco
NServiceBus
RavenDb
Web Sequence Diagrams
Ducksboard<-- NEW Friend!

 



Site Copyright © 2007 CodeBetter.Com
Content Copyright Individual Bloggers

 

Community Server (Commercial Edition)