I'm using the latest preview version of Mono.TextTemplating (2.2.0-preview-0012-ga253e82592) and I've run into an issue importing a library that has its own dependencies. Since I'm still getting used to the dotnet core way of handling libraries, I'll just go ahead and post all the information I think might be relevant:
error : error : Error running transform: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
error : ---> System.IO.FileLoadException: Could not load file or assembly 'Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'. Could not find or load a specific file. (0x80131621)
error : File name: 'Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'
error : ---> System.IO.FileLoadException: Could not load file or assembly 'Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'.
error : at System.Runtime.Loader.AssemblyLoadContext.LoadFromPath(IntPtr ptrNativeAssemblyLoadContext, String ilPath, String niPath, ObjectHandleOnStack retAssembly)
error : at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath)
error : at System.Reflection.Assembly.LoadFrom(String assemblyFile)
error : at System.Reflection.Assembly.LoadFromResolveHandler(Object sender, ResolveEventArgs args) [C:\
error : at System.Runtime.Loader.AssemblyLoadContext.InvokeResolveEvent(ResolveEventHandler eventHandler, RuntimeAssembly assembly, String name)
error : at System.Runtime.Loader.AssemblyLoadContext.OnAssemblyResolve(RuntimeAssembly assembly, String assemblyFullName)
error : at Nucleus.Model.Deserialize(String json)
error : at Microsoft.VisualStudio.TextTemplating39cae511.GeneratedTextTransformation.TransformText()
error : --- End of inner exception stack trace ---
error : at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
error : at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
error : at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
error : at Mono.TextTemplating.CompiledTemplate.Process()
I have made a few attempts of making the error go away, by making sure Newtonsoft.Json is in my nuget cache and also by placing Newtonsoft.Json.dll in the same folder as my library dll. It makes no difference.
Last year I wrote a dotnet core app that could load plugins (dlls) dynamically. If I recall correctly, I had a similar issue with my own app, that I resolved by using the AssemblyDependencyResolver added in 3.0 (https://docs.microsoft.com/en-us/dotnet/core/tutorials/creating-app-with-plugin-support). Is it possible that a similar change should be implemented in T4, or am I missing an easier solution?