问题显示:
Error 6 Compiling transformation: 'Microsoft.VisualStudio.TextTemplatingBED07DAE3B6FD53FA947017E5A5F7A123173F8AEEBD8059AD94FFEA4200EC409BE022035F5E3463EFD6E2867E0DEFBDC09BAEEE8B986A775611AFBBB7D110480.GeneratedTextTransformation' does not contain a definition for 'Host' and no extension method 'Host' accepting a first argument of type 'Microsoft.VisualStudio.TextTemplatingBED07DAE3B6FD53FA947017E5A5F7A123173F8AEEBD8059AD94FFEA4200EC409BE022035F5E3463EFD6E2867E0DEFBDC09BAEEE8B986A775611AFBBB7D110480.GeneratedTextTransformation' could be found (are you missing a using directive or an assembly reference?) e:\Projects\XYX\XYX.Server\MarketDataModuleClientInterface\api.helper.tt 24 50 IMarketDataModuleClientlLibrary
其实问题很简单:
<#@ template hostspecific="true" language="C#" #> <#@ output extension=".txt" #> <#@ import namespace="System.CodeDom.Compiler" #> <# string message = "test message"; this.Host.LogErrors(new CompilerErrorCollection() { new CompilerError( this.Host.TemplateFile, // Identify the source of the error. 0, 0, "0", // Line, column, error ID. message) }); // Message displayed in error window. #>
注意第一行: hostspecific="true"
如果是 false就会出现最前面的那个错误