Entity framework 4 EF.Utility.CS.t包含和MSBuild

Entity framework 4 EF.Utility.CS.t包含和MSBuild,entity-framework-4,msbuild,t4,Entity Framework 4,Msbuild,T4,我在获取引用EF.Utility.CS.ttinclude的.tt文件的MSBuild脚本转换时遇到问题 如果我在VS2010中运行生成,它可以正常工作,但是当我通过命令行运行自定义构建脚本时,我会得到 TextTransform "C:\SourceControl\SVN\PathToFile\myttFile.tt" C:\SourceControl\SVN\PathToFile\myttFile.tt(9,4): error : There was an error loading th

我在获取引用EF.Utility.CS.ttinclude的.tt文件的MSBuild脚本转换时遇到问题

如果我在VS2010中运行生成,它可以正常工作,但是当我通过命令行运行自定义构建脚本时,我会得到

 TextTransform "C:\SourceControl\SVN\PathToFile\myttFile.tt"
C:\SourceControl\SVN\PathToFile\myttFile.tt(9,4): error : There was an error loading the include file 'EF.Utility.CS.ttinclude'. The transformation will not be run. The following Exception was thrown: [C:\SourceControl\SVN\PathToBuildScript\build.xml]
  System.IO.FileNotFoundException: Could not find file 'C:\SourceControl\SVN\PathToFile\EF.Utility.CS.ttinclude'.
  File name: 'C:\SourceControl\SVN\PathToFile\EF.Utility.CS.ttinclude'
     at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
     at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath)
     at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
     at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize)
     at System.IO.StreamReader..ctor(String path)
     at Microsoft.VisualStudio.TextTemplating.CommandLine.CommandLineHost.ReadFileContent(String fileName)
     at Microsoft.VisualStudio.TextTemplating.CommandLine.CommandLineHost.LoadIncludeText(String requestFileName, String& content, String& location)
     at Microsoft.VisualStudio.TextTemplating.Engine.ProcessIncludeDirective(Directive directive, ITextTemplatingEngineHost host)
C:\SourceControl\SVN\PathToBuildScript\build.xml(30,5): error MSB3073: The command "TextTransform "C:\SourceControl\SVN\PathToFile\myttFile.tt"" exited with code 1.
如果我引用EF.Utility.CS.t包含的绝对路径,我会得到:

  TextTransform "C:\SourceControl\SVN\PathToFile\myttFile.tt"
EXEC : error : An expression block evaluated as Null [C:\SourceControl\SVN\PathToBuildFile\build.xml]
     at Microsoft.VisualStudio.TextTemplating.ToStringHelper.ToStringWithCulture(Object objectToConvert)
     at Microsoft.VisualStudio.TextTemplatinga265b58e2b114039856ebd504775f376.GeneratedTextTransformation.TransformText() in c:\SourceControl\SVN\PathToFile\myttFile.tt:line 77
     at Microsoft.VisualStudio.TextTemplating.TransformationRunner.RunTransformation(TemplateProcessingSession session, String source, ITextTemplatingEngineHost host, String& result)
C:\SourceControl\SVN\PathToBuildFile\build.xml(30,5): error MSB3073: The command "TextTransform "C:\SourceControl\SVN\PathToFile\myttFile.tt"" exited with code 1.

任何帮助都很好:)

显示您正在运行的模板myttFile.tt由于执行模板TransformText()而输出任何内容失败

如果看不到myttFile.tt中的逻辑,就很难说出什么

VisualStudio11如果您

设置

加 System.Diagnostics.Debugger.Launch(); 在模板的代码部分,VS11将启动调试器,您可以调试t4

对不起,我刚明白过来。您的模板很可能依赖visual studio作为其宿主。在模板中的某个地方,您有hostspecific=true


简而言之:在TextTransform.exe中添加-I标志以解决此问题,如下所示:

第1步: 创建一个映射到TextTransform的EF6的环境变量,如下所示:

这将创建一个Windows能够理解的变量VS140COMNTXTTRANSFORM

第二步:textcransform.exe命令中包括-I标志,如下所示:

TextTransform.exe -I "%VS140COMNTXTTRANSFORM%" -out filename.tt

您是否尝试过使用-I开关调用texttransform.exe以及EF.Utility.CS.ttinclude的路径?路径可能是:c:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\Templates\Includes\或c:\Program Files(x86)\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\Templates\Includes\很好,其他解决方案都不起作用