本文介绍了如何在T4编译中获取CustomToolNamespace.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好乡亲,

我想我去对地方了.

我在* .csproj中有以下定义:

I have following definition in *.csproj:

  <ItemGroup>
    <Compile Include="LIBAR_FRAES_INFO\SQL\Delete_Row.cs">
      <Generator>TextTemplatingFilePreprocessor</Generator>
      <CustomToolNamespace>LiProd.Sql.LIBAR_FRAES_INFO</CustomToolNamespace>
      <DependentUpon>Delete_Row.tt</DependentUpon>
      <AutoGen>True</AutoGen>
      <DesignTime>True</DesignTime>
      <LastGenOutput>Delete_Row.cs</LastGenOutput>
    </Compile>
  </ItemGroup>


也有一些重复定义:

    <Content Include="LIBAR_FRAES_INFO\SQL\Delete_Row.tt">
      <Generator>TextTemplatingFilePreprocessor</Generator>
	  <CustomToolNamespace>LiProd.Sql.LIBAR_FRAES_INFO</CustomToolNamespace>
      <LastGenOutput>Delete_Row.cs</LastGenOutput>
    </Content>

我还可以将任何定义放在* .csproj或* .sln中的任何位置-生成文件.

I also can put any definition to any place in *.csproj or *.sln - files are generated.

我正在寻找如何在< CustomToolNamespace> LiProd.Sql.LIBAR_FRAES_INFO</CustomToolNamespace>"特定模板作为名称空间.

I looking how to put a whot-is-defined in <CustomToolNamespace>LiProd.Sql.LIBAR_FRAES_INFO</CustomToolNamespace> for specific template as a namespace.

据我所知-我确实在* .csproj中添加了一个Import部分:

As far as I get - I do add an Import section to my *.csproj :

<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v14.0\TextTemplating\Microsoft.TextTemplating.targets" />
<PropertyGroup>
    <TransformOnBuild>true</TransformOnBuild>
	<TransformOutOfDateOnly>false</TransformOutOfDateOnly>
</PropertyGroup>


这将在编译时强制重新编译T4,但将其用作命名空间的方式是:

This force to re-compile T4 on the build, but as a Namespace are used following: 

    <PropertyGroup>
      <!-- Unless another namespace has been specified, use the project namespace as the
      default namespace from pre-processed files. -->
      <PreprocessTemplateDefaultNamespace Condition=" $(PreprocessTemplateDefaultNamespace)=='' ">$(RootNamespace)</PreprocessTemplateDefaultNamespace>
    </PropertyGroup>

对于整个项目,我需要使用CustomToolNamespace而不是整个项目的RootNamespace.

Instead of RootNamespace for a whole project I need to use CustomToolNamespace for specific template.

据我了解的技术,我需要导入其他规则以覆盖现有的PreprocessTemplateDefaultNamespace.

As far as I understand a technology I need to import additional rules to overwrite existing PreprocessTemplateDefaultNamespace. 

我确实搜索* .target,其中包含使用CustomToolNamespace的示例,但找不到合适的对象.

I do search for a *.targets which contain an example of using CustomToolNamespace, but didn't find any suitable.

有人可以在说明* .targets的过程中指出我的文档吗?

Can somebody point me on documentation where are described process of creating *.targets?

有人可以提供* .target的示例,该目标使用CustomToolNamespace作为特定模板吗?

Can somebody provide an example of *.targets which used CustomToolNamespace for a specific template?

推荐答案

	<Content Include="LIBAR_FRAES_INFO\SQL\Delete_Row.tt">
      <Generator>TextTemplatingFilePreprocessor</Generator>
	  <CustomToolNamespace>LiProd.Sql.LIBAR_FRAES_INFO</CustomToolNamespace>
      <LastGenOutput>Delete_Row.cs</LastGenOutput>
	  <ClassNamespace>LiProd.Sql.LIBAR_FRAES_INFO</ClassNamespace>
    </Content>

我确实向内容"部分添加了ClassNamespace(生成了我的* .csproj文件,因此相对容易).

I do add a ClassNamespace to Content section (my *.csproj file are generated, so, it relatively easy).

我仍在寻找使用* .targets的解决方案.

I still looking for solution using *.targets.


这篇关于如何在T4编译中获取CustomToolNamespace.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 06:44