简体   繁体   English

单声道TextTransform.exe

[英]Mono TextTransform.exe

I'm trying to use the TextTransform executable from MonoDevelop. 我正在尝试使用MonoDevelop的TextTransform可执行文件。 I'm using sharpdevelop as my IDE and created a simple texttemplate file to check it out and all went well. 我将Sharpdevelop用作我的IDE,并创建了一个简单的texttemplate文件将其检出,一切正常。 The file was generated on save. 该文件是在保存时生成的。 When I went to use the executable I was continually running into errors about not finding files. 当我去使用可执行文件时,我一直在遇到找不到文件的错误。 As an example I was using <#@ assembly name="System.Core" #> and this would output when I tried using the executable: 举例来说,我使用的是<#@ assembly name="System.Core" #> ,当我尝试使用可执行文件时,它将输出:

"ERROR Metadata file 'System.Core' could not be found". “找不到错误元数据文件'System.Core'”。

I tried a couple different things like passing -P argument(though I'm not sure I did that right). 我尝试了几种不同的方法,例如传递-P参数(尽管我不确定我是否做对了)。 It wasn't until I changed the tt file itself to use <#@ assembly name="System.Core.dll" #> instead of "System.Core" that the executable was successful. 直到我将tt文件本身更改为使用<#@ assembly name="System.Core.dll" #>而不是“ System.Core”为止,可执行文件才成功。 However, after changing to include the file extension SharpDevelop now gives this output when I save the tt file. 但是,在更改为包含文件扩展名之后,SharpDevelop现在在保存tt文件时给出此输出。

Error loading code-completion information for System.Core.dll from System.Core.dll: Could not find assembly file. 从System.Core.dll加载System.Core.dll的代码完成信息时出错:找不到程序集文件。

Is there something I'm missing in order to get both to work? 为了使两者都能正常工作,我缺少什么吗? I don't really need both but would like to understand why this happens. 我并不需要两者,但想了解为什么会这样。

That seems like a bug in TextTransform.exe since I would expect it to allow an assembly name instead of the filename. 这似乎是TextTransform.exe中的错误,因为我希望它允许程序集名称而不是文件名。 I can also reproduce it in MonoDevelop with the following T4 template. 我还可以使用以下T4​​模板在MonoDevelop中重现它。

<#@ template language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>

<html><body>
 The date and time now is: <#= DateTime.Now #>
</body></html>

The above template works fine with SharpDevelop 4.4. 上面的模板可与SharpDevelop 4.4配合使用。

Changing the template so it uses System.Core.dll in the assembly directive also works with SharpDevelop. 更改模板,使其在Assembly指令中使用System.Core.dll,也可以与SharpDevelop一起使用。 The code completion error can be ignored. 代码完成错误可以忽略。 This error is being incorrectly generated by the parser. 解析器错误地生成了此错误。 So you could just leave the assembly directive using System.Core.dll for now. 因此,您现在可以只使用System.Core.dll离开Assembly指令。

Visual Studio also supports both versions of the template with or without the .dll file extension. Visual Studio还支持带有或不带有.dll文件扩展名的模板的两个版本。

Interestingly SharpDevelop actually uses Mono's T4 templating engine to run these T4 templates. 有趣的是,SharpDevelop实际上使用Mono的T4模板引擎来运行这些T4模板。 They are obviously doing something different. 他们显然在做些不同的事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM