使用 VS 2015 在构建中生成 T4 时出错
Error Generating T4 on Build using VS 2015
我正在使用 Visual Studio 2015 更新 3。我尝试将 TextTransform.exe 与 dp 标志一起使用,但出现此错误:
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)
产生错误的行:
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"
我查找的其他问题:
- Get Visual Studio to run a T4 Template on every build(我以接受的答案为基础)
- Processor Named ‘T4VSHost’ Could Not Be Found For The Directive Named ‘CleanupBehavior’
- Generating T4 on Build using VS 2012(不如批处理文件灵活)
到目前为止,我所知道的是所有路径都是正确的,并且我的注册表中的 T4VSHost 定义是正确的。
限制:
- 我不能modify/move .tt 文件
- 我无法移动程序集文件或 ttinclude 文件(尽管我尝试过)
我非常想避免修改 EF.CS.ttinclude 文件。是什么导致了这个问题?
dp 开关缺少 class 名称,它应该有指令处理器的名称、完整类型名称和程序集。
指令处理器语法:
-dp <处理器名称>!!<程序集名称|代码库>
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"
我正在使用 Visual Studio 2015 更新 3。我尝试将 TextTransform.exe 与 dp 标志一起使用,但出现此错误:
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)
产生错误的行:
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"
我查找的其他问题:
- Get Visual Studio to run a T4 Template on every build(我以接受的答案为基础)
- Processor Named ‘T4VSHost’ Could Not Be Found For The Directive Named ‘CleanupBehavior’
- Generating T4 on Build using VS 2012(不如批处理文件灵活)
到目前为止,我所知道的是所有路径都是正确的,并且我的注册表中的 T4VSHost 定义是正确的。
限制:
- 我不能modify/move .tt 文件
- 我无法移动程序集文件或 ttinclude 文件(尽管我尝试过)
我非常想避免修改 EF.CS.ttinclude 文件。是什么导致了这个问题?
dp 开关缺少 class 名称,它应该有指令处理器的名称、完整类型名称和程序集。
指令处理器语法:
-dp <处理器名称>!
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"