Skip to content

Indicate source of explicit/autogenerated binding redirect conflict in error #4302

@kg

Description

@kg

In cases where there are assembly binding redirect conflicts, the diagnostic messages you get from msbuild can be pretty bad and sometimes provide inaccurate/incorrect advice. For example, I'm troubleshooting a scenario right now where each binding redirect error gives me advice that just leads to the other error:

MSB3276: Found conflicts between different versions of the same dependent assembly. Please set the "AutoGenerateBindingRedirects" property to true in the project file

Then if as advised, I set the property:

The explicit binding redirect on "Microsoft.Build.Framework, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" conflicts with an autogenerated binding redirect. Consider removing it from the application configuration file or disabling autogenerated binding redirects.

I don't necessarily view either of these errors as msbuild defects - I think they're probably both correct representations of whatever is going on when I'm trying to compile msbuild locally. I wanted to file this issue though because I think these are bad diagnostic messages and they make it hard to debug the problem.

As far as I can tell there's no guidance given here on where the redirects that conflict are defined, or where the conflicting versions are referenced. When I look around for info on these errors I can't find any information on how you would figure that out, either, just lots of people talking about turning the auto generate mode on or off.

So as a starting point, I think that "please set" message might be inappropriate since that implies it will fix it, when it may just create a different issue - we're encouraging people to just set that property on when that may be masking some other root cause they could address.

More importantly though there needs to be some way to get insight into where the binding redirects are coming from, preferably described in the error message so people can actually find it. The diagnostic info is definitely not something you will find by searching for MSB3276 on google (or in a brief search through the msbuild docs).

Could we expand msbuild to, for example:

  • For the first one, list out all the conflicting versions and where those references are from
  • For the second one, list out the source of the explicit binding redirects along with the autogenerated redirect

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: DebuggabilityIssues impacting the diagnosability of builds, including logging and clearer error messages.help wantedIssues that the core team doesn't plan to work on, but would accept a PR for. Comment to claim.triaged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions