SaaS CMS has officially launched! Learn more now.

Binding redirect overwiriting on installing nuget package


Hi All!

I am having a problem with automatic bindingRedirect overwriting, when installing nuget packages.

In most cases that behavior is expected, but in my case the problem is that the max value of the version range is decreased.

My main project has the following binding redirect:

<assemblyIdentity name="EPiServer.Framework" publicKeyToken="8fe83dea738b45b7" culture="neutral"/>
<bindingRedirect oldVersion="" newVersion=""/>

And the nuget package i am installing has the following:

<assemblyIdentity name="EPiServer.Framework" publicKeyToken="8fe83dea738b45b7" culture="neutral" />
<bindingRedirect oldVersion="" newVersion="" />

As you can see the problem is that the minor version in the package is higher than the version in the consuming package, therefore it is out of the version range in that particular binding. That creates an error when starting the base project, about missing assemblies.

A fix for this is to correct the range of the versions in the binding in the consuming project after the nuget package installs. But that is cumbersome and I would not want to push that responsibility on the people that would use the nuget package.

So is there any way to mitigate this problem, without manually parsing the packages.config file in the nuget a1 script file?

Jan 10, 2019 12:03

if I understand you correctly.. usually there is a reason why nuget package authors are setting min version for the dependencies packages. for me it looks like package requires "" version of the framework, but your project is using only "". am I correct? if it's so then I would recommend to upgrade your project to "" if you really need to use that package.

Jan 12, 2019 22:03

"for me it looks like package requires "" version of the framework, but your project is using only "". am I correct?"

That is indeed the case.

Should the content of the global Web.config change after package import? Because that's happening now, when I import the package.

Original package content:

<assemblyIdentity name="EPiServer.Framework" publicKeyToken="8fe83dea738b45b7" culture="neutral" />
<bindingRedirect oldVersion="" newVersion="" />

changes automatically after package import to:

<assemblyIdentity name="EPiServer.Framework" publicKeyToken="8fe83dea738b45b7" culture="neutral" />
<bindingRedirect oldVersion="" newVersion="" />

So every time I import the package, I have to change this binging back to

I don't think this is the correct behavior. Or maybe it is?

Jan 14, 2019 11:40

for me it looks like package behaves exactly as it should. if you install version -> it will make binding redirects from any version up to to use exactly this version which is being installed -

where did you get - binding? are you sure that on v12 release - Episerver will be able to fallback to

for me - it just looks that your web.config is wrong.

Jan 14, 2019 12:04

The Package has dependancy set to

I have the same dependancy installed in the main project, version I manually set the range in bindings to to include the dependancy from the package. All is well. I know for a fact, that the package will work with that version of the dependancy.

And I nave to set this every time I install the package.

Can I turn this manual bindings rewrite off? MSDN says that the automatic bindings redirect is not set in ASP projects. And somehow it is.

Jan 14, 2019 13:37

still I would say that package behaves by design and mix-match various version is left on your own risk :)

anyway - assembly redirect is part of the package and is executed during the install just to ensure that configuration is correct. check packages\\tools\AssemblyRedirects.ps1

Jan 14, 2019 14:39

I have created this package. And there was no ps1 script attached :(

Jan 14, 2019 15:24

is package publicly available?

Jan 15, 2019 8:21

No, not yet.

Jan 15, 2019 16:08

I would need to look at code to conclude anything further..

Jan 15, 2019 17:10

I cannot share the code right now. But i am gratefull for your help.

I will try to post an update in case of a solution to this problem.

Jan 16, 2019 12:41

Hello, has the problem been solved? I'm a little unclear. The version of nuget package is, but the redirection range generated by nuget is 0-

Nov 24, 2021 10:45
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.