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
Steps to reproduce
UserProject)Newtonsoft.Json 7.0.1. (I'll refer to the added package asToolX)Newtonsoft.Json 8.0.3toUserProject.UserProjectToolX.exein thebin/Debug/...folder ofUserProjectExpected behavior
ToolX.exeruns as expectedActual behavior
Newtonsoft.Json 7.0.1Reason
There's a binding redirect generated for
UserProject.exebut not for the addedToolX.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-toolit launches the portable version ofmy-toolwhich 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 ofNewtonsoft.Json./cc @DamianEdwards @Eilon @davidfowl @muratg @danroth27 @piotrpMSFT @brthor @natemcmaster @prafullbhosale @pranavkm