I have a solution with multiple projects in it (~400). A lot of them are using newtonsoft.json
library. Some of them are using different version of the library. In a host project for web app, there is no direct reference to newtonsoft.json
. Also, I believe, there are dependencies to packages that depend on newtonsoft.json
. However, in bin folder of that project I began getting newtonsoft.json 9.0
instead of newtonsoft.json 11.0
as it used to be. And it causes load exception in runtime due to invalid version. If I include direct reference to newtonsoft.json 11.0
, it still puts version 9.0 in the bin folder even if I clear all bin,obj folders. I use PackageReference for managing dependencies, and everything is in .net 4.6.1
; I use binding redirects to resolve issues with different versions of the same library.
My question is if there is a way to diagnose how particular dll of package ref appears in bin folder? I would like to see some sort of comprehensive trace of dependency resolution so that I can fix it without using "trial and error" approach.
Upd.
Actually, thanks guys for pointing to structured logging. You are the best! So the issue was that one of the project had <OutputPath>
pointing to the bin
folder of the host project. So when the project was built, it was overriding binaries in the host project. Apparently, build order has changed due to continuous reference shuffling and the project with wrong <OutputPath>
started building last. To find this out 1) I Newtonsoft.Json was recorded in DoubleWrites
section 2) analyzing location from double writes I found out in _CopyFilesMarkedLocal
section
Copying file from "\VenomousProject\bin\Debug\Newtonsoft.Json.dll" to "HostProject\bin\Debug\Newtonsoft.Json.dll".
That was it.
You can try MSBuild Binary and Structured Log Viewer (https://msbuildlog.com/)
msbuild -bl
- you will get msbuild.binlog