I have the need to do JSON schema generation within a T4 template, and found Newtonsoft's new Schema class more than adequate for the purpose at hand (within a console application, tested), however, I cannot seem to make it play ball with the rest, as the instance to Newtonsoft always returns null.
T4 declaration:
<#@ template debug="true" hostspecific="true" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ assembly name="Newtonsoft.Json.dll" #>
<#@ assembly name="Newtonsoft.Json.Schema.dll" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ output extension=".cs" #>
The assembly references point to the DLL files, and I have folder look ups set in the project settings for the project, screen shot below:
Trying to do something like the below, fails, because Newtonsoft cannot be found:
var schema = Newtonsoft.Json.Schema.JSchema.Parse(jsoncontent);
Error thrown is: Metadata file 'Newtonsoft.Json.Schema.dll" could not be found.