cake-contrib/Cake.Json

Getting error from cake when referencing Cake.Json

marking opened this issue · 3 comments

I've got a very simple build.cake file that has the following line at the top:

#addin "Cake.Json"

This downloads Cake.Json and Newtonsoft.Json and places them in the proper directories, but then cake.exe throws the following error:

Error: Could not load file or assembly 'Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.

I took a quick look in the nupkg file for Cake.Json and it is referencing the 'wrong' full name for Newtonsoft.Json.

Let me know if you'd like more information.

So, it turns out that the Newtonsoft.Json.dll that is installed when the #addin directive is executed has the proper Full Name:

Name                  : Newtonsoft.Json
Version               : 7.0.0.0
CultureInfo           :
CultureName           :
CodeBase              : file:///C:/src/cake-example/tools/Addins/Newtonsoft.Json/lib/net45/Newtonsoft.Json.dll
EscapedCodeBase       : file:///C:/src/cake-example/tools/Addins/Newtonsoft.Json/lib/net45/Newtonsoft.Json.dll
ProcessorArchitecture : MSIL
ContentType           : Default
Flags                 : PublicKey
HashAlgorithm         : SHA1
VersionCompatibility  : SameMachine
KeyPair               :
FullName              : Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed

However, Cake (core) or Cake.Json or the compiler itself cannot find it. I enabled the fusion logs for both Default and NativeImage for Cake.Json and Newtonsoft.Json, but I don't see why the NativeImage binding for Newtonsoft.Json is failing.
Default-Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed.txt
Default-Cake.Json, Version=1.0.5780.19234, Culture=neutral, PublicKeyToken=null.txt

NativeImage-ExplicitBind!FileName=(Newtonsoft.Json.dll).txt
NativeImage-ExplicitBind!FileName=(Cake.Json.dll).txt

I'm starting to wonder if this is a problem with a non-strong named assembly referencing a strongly named assembly, but that's just a guess.

One last bit, then I'm done for tonight. 😄

I copied the Newtsonsoft.Json files into the tools\cake directory so they were co-located with cake.exe (I noticed in the fusion log that this was one of the spots it was looking), and the build.cake file ran without error. So, it's not a strong naming issue, but an install location issue.

My problem was that I happened to clone https://github.com/cake-build/example.git to get started. This example was referencing an older version of Cake. Once I upgraded to Cake version 0.6.0 in the .\tools\packages.config, everything worked as advertised.

thanks for reading.