I have a custom dll, which has a class in it, and (for simplicity's sake) there's a method on it which'll return a string.
I have a project, which references said dll, and I want to use a (not preprocessed) T4 template in that project, which calls said method. I've tried this:
<#@ template debug="true" hostspecific="false" language="C#" #>
<#@ assembly name="MyDLL.dll" #>
<#@ output extension=".cs" #>
<#
var template = new MyDLL.MyNamespace.MyClass();
this.Write(template.Run());
#>
I got the following errors:
Error 14 Compiling transformation: Metadata file 'MyDLL.dll' could not be found
Error 13 A namespace cannot directly contain members such as fields or methods
even if MyClass.Run() is simply a return "//hello";
t4 template is used to scaffold a DbContext class for the database, and the EntityType. t4 template is used to scaffold entity type classes for each table and view in the database.
Seems like Your problem:
Error Compiling transformation: Metadata file 'dotless.Core' could not be found
It's due to compatibility break described here:
http://weblogs.asp.net/lhunt/archive/2010/05/04/t4-template-error-assembly-directive-cannot-locate-referenced-assembly-in-visual-studio-2010-project.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With