2011-05-26 68 views
1

我試圖運行TextTransform.exe使用T4模板文件生成代碼。 模板文件依賴於T4Toolbox(具體而言,它包含實現T4Toolbox.Template類的類)。使用T4Toolbox時運行TextTransform.exe的問題

因此,它包括文件t4toolbox.tt,其中包含以下指令:

<#@ dte processor="T4Toolbox.DteProcessor" #> 

<#@ TransformationContext processor="T4Toolbox.TransformationContextProcessor" #> 

在執行過程中,我得到了兩個引用處理器以下錯誤:

C:\Program Files\T4 Toolbox\t4toolbox.tt(1,4) : error : A processor named 'T4Toolbox.DteProcessor' could not be found for the directive named 'dte'. The transfo 
rmation will not be run. The following Exception was thrown: 
System.IO.FileNotFoundException: Failed to load directive processor T4Toolbox.DteProcessor. 
    at Microsoft.VisualStudio.TextTemplating.CommandLine.CommandLineHost.ResolveDirectiveProcessor(String processorName) 
    at Microsoft.VisualStudio.TextTemplating.Engine.ProcessCustomDirectives(ITextTemplatingEngineHost host, TemplateProcessingSession session, List`1 directivesT 
oBeProcessed) 

我運行帶有以下參數的exe文件:

TextTransform.exe 
-I "C:\Program Files\T4 Toolbox" 
-P "[Framework3.5],[VS2008 PublicAssemblies]" 
-dp "XsdProcessor!T4Toolbox.XsdProcessor!T4Toolbox.dll" 
-r "T4Toolbox.dll" mytemplate.tt 

我試過在多重指令處理器中加入多個-dp參數,並用逗號分隔列表(我可以看到DteProcessorTransformationContextProcessor都在T4Toolbox中實現,所以推測其語法類似於XsdProcessor的規範?)

關於如何擺脫這些錯誤的任何想法?模板生成在Visual Studio中完美運行。

回答

1

我設法通過對命令行參數進行一些調整來解決指出的錯誤。 TextTransform.exe似乎需要單獨指定多個路徑或指令。我也有加工裝配不正確(-R)

例如: TextTransform.exe -I "C:\Program Files\T4 Toolbox" -P "[path1]" -P "[path2]" -dp "T4Toolbox.DteProcessor!T4Toolbox.DteProcessor!T4Toolbox.dll" -dp "T4Toolbox.TransformationContextProcessor!T4Toolbox.TransformationContextProcessor!T4Toolbox.dll"
-r Microsoft.VisualStudio.TextTemplating.VSHost.dll" mytemplate.tt

然而,不幸的是,解決這些夫婦的問題,導致了死衚衕。 目前不支持使用T4Toolbox。

http://t4toolbox.codeplex.com/discussions/52069

相反,我期待在調用的MSBuild。 以下是一個很好的參考: http://www.olegsych.com/2010/04/understanding-t4-msbuild-integration/#ConfiguringTransformationEnvironment

+0

仍然沒有其他辦法解決這個問題嗎? – Gluip 2016-11-09 12:42:14