Sdk: Binding redirect file is not generated for referenced desktop packages that contain executables.

Created on 14 Apr 2016  路  4Comments  路  Source: dotnet/sdk

Steps to reproduce

  • Create a project that has a net451 TFM (I'll refer to the project as UserProject)
  • Add a reference to a package that contains an executable that expects Newtonsoft.Json 7.0.1. (I'll refer to the added package as ToolX)
  • Add a reference to Newtonsoft.Json 8.0.3 to UserProject.
  • Build UserProject
  • Execute ToolX.exe in the bin/Debug/... folder of UserProject

    Expected behavior

  • ToolX.exe runs as expected

    Actual behavior

  • Type load exception for Newtonsoft.Json 7.0.1

    Reason

There's a binding redirect generated for UserProject.exe but not for the added ToolX.exe. We should be generating a binding redirect file for the added exe in the case that it's being brought into a desktop tfm.

We (ASP.NET team) are building tools that are capable of loading desktop targeting user projects; we do this by referencing the tool once in the tools node and again in the dependencies node. When you run dotnet my-tool it launches the portable version of my-tool which will then build the users project and invoke itself in the built output since it was referenced also in the dependencies node. This is what made the above issue apparent, we were trying to invoke a net451 tool in a user project that targeted a higher version of Newtonsoft.Json.

/cc @DamianEdwards @Eilon @davidfowl @muratg @danroth27 @piotrpMSFT @brthor @natemcmaster @prafullbhosale @pranavkm

Most helpful comment

@Sridhar-MS will have a fix today.

All 4 comments

@Sridhar-MS will have a fix today.

Fix is in PR, but needs test cases.

@Sridhar-MS can you create an RTM issue to track generating the redirects for publish output?

Fixed by dotnet/cli#2586

Was this page helpful?
0 / 5 - 0 ratings