Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The "EnsureBindingRedirects" task failed unexpectedly

When I create new ASP.NET 4.5 web forms application from vs2012 and update all nuget packages, I receive this error on build:

Error 1 The "EnsureBindingRedirects" task failed unexpectedly. System.NullReferenceException: Object reference not set to an instance of an object. at Roxel.BuildTasks.EnsureBindingRedirects.MergeBindingRedirectsFromElements(IEnumerable`1 dependentAssemblies) at Roxel.BuildTasks.EnsureBindingRedirects.Execute() at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() at Microsoft.Build.BackEnd.TaskBuilder.d__20.MoveNext()

like image 293
Ivan Lewis Avatar asked May 30 '13 09:05

Ivan Lewis


3 Answers

It's a bug in Microsoft.Bcl.Build and to solve it you have to put culture info in the assemblyIdentity-part of web.config or app.config.

For example if you have:

<dependentAssembly>
   <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
   <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>

change it to:

<dependentAssembly>
    <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
like image 117
Henrik Fransas Avatar answered Nov 06 '22 11:11

Henrik Fransas


I had this error but slightly different, took me 45 minutes to figure it out so thought I'd better get this out there.

Was experiencing the "EnsureBindingRedirects" task failed unexpectedly problem but mine came from an XmlException:

(...)\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets(97,5): error MSB4018: System.Xml.XmlException: '=' is an unexpected token. The expected token is ';'. Line 39, position 175.

Turns out the cause was that I'd recently added an entry to my web.config's appSettings where the value was a URL that contained an ampersand (&).

Ampersands need to be escaped in XML, even in attribute values.

I changed all the & in the URL value to &amp; and it built without issue.

like image 41
JHo Avatar answered Nov 06 '22 13:11

JHo


In my case issue have revealed after I merged a branch which broke my web.config file. It added comment character sequence <!-- without closing part -->.

Making file markup valid fixed the issue.

like image 14
Vova Bilyachat Avatar answered Nov 06 '22 11:11

Vova Bilyachat