visual-studio-2015template-enginet4

Error Generating T4 on Build using VS 2015


I'm using Visual Studio 2015 update 3. I tried using TextTransform.exe with the dp flag, but I got this error :

C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\Templates\Includes\EF6.Utility.CS.ttinclude(1,4): error : A processor named 'T4VSHost' could not be found for the directive named 'CleanupBehavior'. The transformation will not be run.  The following Exception was thrown:
System.IO.FileNotFoundException: Failed to load directive processor T4VSHost. ---> System.IndexOutOfRangeException: L'index se trouve en dehors des limites du tableau.
 à Microsoft.VisualStudio.TextTemplating.CommandLine.DirectiveProcessorConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
 à Microsoft.VisualStudio.TextTemplating.CommandLine.CommandLineHost.ResolveDirectiveProcessor(String processorName)
 à Microsoft.VisualStudio.TextTemplating.CommandLine.CommandLineHost.ResolveDirectiveProcessor(String processorName)
 à  Microsoft.VisualStudio.TextTemplating.Engine.ProcessCustomDirectives(ITextTemplatingEngineHost host, TemplateProcessingSession session, IEnumerable`1 directivesToBeProcessed)

Line that generated the error :

 texttransform -out "P:\<Path to project>\Model.cs" -I "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\Templates\Includes" -dp T4VSHost"C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Microsoft.Data.Entity.Design.dll" "P:\<Path to project>\Model.tt"

Other issues I looked up :

What I know so far is that all paths are correct and that T4VSHost's definition in my registry is correct.

Restrictions :

I would very much like to avoid modifying the EF.CS.ttinclude file. What could be causing this issue?


Solution

  • The -dp switch is missing the class name, it should have name, full type name, and assembly of the directive processor.

    Directive processor syntax:

    -dp &lt;processorName&gt;!&lt;className&gt;!&lt;assemblyName|codeBase&gt;
    

    For EF6.Utility.CS.ttinclude specifically, it needs T4VSHost for CleanupBehavior, which is located in Microsoft.Data.Entity.Design.dll:

    Directive processor for CleanupBehavior:

    -dp T4VSHost!Microsoft.Data.Entity.Design.VisualStudio.Directives.FallbackT4VSHostProcessor!"C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Microsoft.Data.Entity.Design.dll"