开发者

EF.Utility.CS.ttinclude and MSBuild

开发者 https://www.devze.com 2023-04-01 14:02 出处:网络
I am having troubles getting my MSBuild script transform a .tt file that references EF.Utility.CS.ttinclude.

I am having troubles getting my MSBuild script transform a .tt file that references EF.Utility.CS.ttinclude.

If i run the generation from withi开发者_JAVA百科n VS2010 it works fine, but when I run my custom build script via the command line I get.

 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.

If I reference the absolute path for the EF.Utility.CS.ttinclude, I get:

  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.

Any help would be great :)


In short: Add the -I flag in TextTransform.exe to solve this problem like so:

Step 1: Create an environment variable mapping to your TextTransform's EF6 Include like so:

EF.Utility.CS.ttinclude and MSBuild

which will create a variable VS140COMNTXTTRANSFORM that Windows understands

Step 2: Include -I flag in the TextTransform.exe command like so:

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


Appears that the template you were running myttFile.tt failed out output anything as a result of the template being executed TransformText();

Can't really tell much without seeing what the logic is inside of myttFile.tt.

Visual Studio 11 if you

set <# template debug = true#>

and add System.Diagnostics.Debugger.Launch(); to the code section of your template, VS 11 will launch the debugger and you can debug your t4.

sorry, just dawned on me. Chances are your template has a dependency on visual studio as its host. somewhere in your templates you have hostspecific = true.

<#@ template hostspecific="true" language="C#" #>

0

精彩评论

暂无评论...
验证码 换一张
取 消