0

我很惊讶地发现两者之间没有联系。我错了吗?

我在项目模板中有一些 tt,我将 $safeprojectname$ 作为要写入的文件名,它似乎没有扩展 tt 文件并相应地创建 cs 文件。

4

2 回答 2

2

您可以将两者一起使用。要设置自定义工具,您需要在 .vstemplate 文件中做一些额外的工作。

这是 VS 2010 中标准 TextTemplate itme 模板的代码。VSDesigner 向导代码在项目上设置自定义工具属性。

 <TemplateContent>
    <ProjectItem TargetFileName="$fileinputname$.tt" ReplaceParameters="false">Prospective.CSharp.tt</ProjectItem>
    <CustomParameters>
      <CustomParameter Name="$itemproperties$" Value="CustomTool" />
      <CustomParameter Name="$CustomTool$" Value="TextTemplatingFileGenerator" />
    </CustomParameters>
  </TemplateContent>
  <WizardExtension>
    <Assembly>Microsoft.VSDesigner, Version=10.0.0.0, Culture=Neutral, PublicKeyToken=b03f5f7f11d50a3a</Assembly>
    <FullClassName>Microsoft.VSDesigner.ProjectWizard.ItemPropertyWizard</FullClassName>
  </WizardExtension>
于 2011-01-25T21:57:45.530 回答
1

Yes it can use them. Visual Studio recognizes files with a .tt extension as T4 template files and expands them appropriately. Oleg Sych has a lot of very good information about them. This one may be what you are looking for.

于 2011-01-25T00:32:53.143 回答