T4没有Visual Studio的? [英] T4 without Visual Studio?

查看:169
本文介绍了T4没有Visual Studio的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想wireup约$ C C根模板$到我的团队的自动化构建过程。我们的供应链管理团队不希望我们的构建机器上的Visual Studio(我有一个很难与争论)。

有没有一种方法来安装T4发动机无Visual Studio的?

解决方案

我们实际上并没有产生code ...我们产生沙堡脚本,我们当然希望是构建服务器上完成。我们已经采取了我们创建了一系列自定义的方法属性用来装点code与形状的文档是如何产生的。因此,我们有一组反映了我们集这些属性.TT文件,并生成沙堡的输入文件(.shfb)。我可以用自定义的工具完成,但T4很好地适应该法案。

反正...我已经证实,可以运行TextTransform.exe没有Visual Studio中。所有你需要的是Microsoft.VisualStudio.TextTemplating.dll present。我创建了一个新的虚拟机,安装了.NET 3.5,并复制以下到文件系统:

  • TextTransform.exe
  • TextTemplate.ico
  • Microsoft.VisualStudio.TextTemplating.dll
  • Test.tt(这是我创建的)

Test.tt是这样的:

 <#@模板语言=C#3.5调试=真正的hostspecific =真#>
<#@集名称=的System.Xml#>
<#@导入命名空间=系统#>
<#@导入命名空间=System.Collections中#>
<#@导入命名空间=System.Collections.Generic#>
<#@导入命名空间=的System.Xml#>
<CS#@输出扩展=#>
 

  

测试:   <#= System.DateTime.Now.ToString()#> ...

从VM I执行Test.tt像这样:

  

C:\ TextTransform.exe Test.tt

和test.cs中创建包含

  

测试:2009年6月10日下午5时33分32秒......

胜利!!!!

最难的部分是找到Microsoft.VisualStudio.TextTemplating.dll。我不得不解雇了FileMon和我的箱子里面有Visual Studio中执行的模板。 FileMon的话告诉我在哪里TextTransform.exe从加载它。这可能是在几个地方有可能,但我发现它在GAC在C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.TextTemplating\9.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.TextTemplating.dll.为了浏览到使用Windows资源管理器的位置,我不得不创建一个SUBST,如下所示:

SUBST X:C:\ WINDOWS \组装

然后我可以浏览到X:\ WINDOWS \组装\ GAC_MSIL \ Microsoft.VisualStudio.TextTemplating \ 9.0.0.0__b03f5f7f11d50a3a \并复制该dll

反正...感谢您的想法男性化。希望这可以帮助其他一些可怜的灵魂有一天:)

I'm trying to wireup some code gen templates to my team's automated build process. Our SCM team doesn't want Visual Studio on our build machine (which I have a hard time arguing with).

Is there a way to install the T4 engine without Visual Studio?

解决方案

We're not actually generating code... we're generating Sandcastle scripts and we definitely want that done on the build server. We've taken an approach where we've created a series of custom attributes that we decorate our code with that shapes how the doc is generated. So we have a set of .tt files that reflect our assemblies for these attributes, and generates Sandcastle's input file (.shfb). I could have done it with a custom tool, but T4 fit the bill nicely.

Anyway... I've confirmed that you can run TextTransform.exe without Visual Studio. All you need is the Microsoft.VisualStudio.TextTemplating.dll present. I created a fresh VM, installed .NET 3.5, and copied the following to the file system:

  • TextTransform.exe
  • TextTemplate.ico
  • Microsoft.VisualStudio.TextTemplating.dll
  • Test.tt (something I created)

Test.tt looked like this:

<#@ template language="C#3.5" debug="true" hostspecific="true" #>
<#@ assembly name="System.Xml" #>
<#@ import namespace="System" #>
<#@ import namespace="System.Collections"#>
<#@ import namespace="System.Collections.Generic"#>
<#@ import namespace="System.Xml" #>
<#@ output  extension=".cs" #>

Test: <#=System.DateTime.Now.ToString()#>....

From the VM I executed Test.tt like so:

C:\TextTransform.exe Test.tt

and Test.cs was created containing

Test: 6/10/2009 5:33:32 PM....

VICTORY!!!!

The hardest part was finding Microsoft.VisualStudio.TextTemplating.dll. I had to fire up FileMon and execute a template on my box which has Visual Studio. FileMon then told me where TextTransform.exe was loading it from. This can be in several places potentially, but I found it in the GAC at C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.TextTemplating\9.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.TextTemplating.dll. In order to browse to that location using Windows Explorer, I had to create a subst like so:

subst X: C:\Windows\assembly

then I could browse to X:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.TextTemplating\9.0.0.0__b03f5f7f11d50a3a\ and copy the dll.

Anyway... thanks for the idea mannish. Hopefully this helps some other poor soul someday :)

这篇关于T4没有Visual Studio的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆