Calling Octopus.Client from MSBuild Task

This might be more of an MSBuild specific question but I thought I’d post my problem here in case anyone has any suggestions.

I’ve got an MSBuild task built to target net 4.5.2 from which I call the latest octopus.client which NuGet added a reference to the latest 6.0 json library to my task assembly (and updated the app.config of the task assembly to contain a binding redirect to json 6.0). When I go to use my MSBuild task I get the following error:

Could not load file or assembly ‘Newtonsoft.Json, Version=, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed’ or one of its dependencies

I’m guessing that Octopus.Client has been compiled to use json 4.5? To get it to work I specifically asked nuget to install json 4.5 into my MSBuild task assembly. My question is: Is that what I’m expected to do?

If I was calling Octopus.Client from my own exe I’d just update the exe’s config with a binding redirect, but since MSBuild.exe is the host I can’t update the config file with a binding redirect (how do I do binding redirects within the MSBuild process?).

Anyway, I’ve got this working so this isn’t urgent, but am just looking for some thoughts since MSBuild and binding redirection and NuGet all aren’t my speciality.