【发布时间】:2016-03-31 12:03:34
【问题描述】:
问题是:有没有办法在 *.tt 文件中进行设置,以便将生成的文件设置为指定的构建操作?
问题是我正在使用模板生成 SQL 脚本。我将此脚本用作数据库项目中的预部署脚本。目前,每次重新生成文件时,我都必须手动将 Build Action 设置为 Pre-Deploy - 我想自动化它。
这两个文件——模板和它生成的 SQL——都包含在项目中。在 Project (*.sqlproj) 中,它们是下一个标签:
<PreDeploy Include="Migration\PreDeployScript.sql">
<DependentUpon>Migration\PreDeployScript.tt</DependentUpon>
</PreDeploy>
和
<None Include="Migration\PreDeployScript.tt">
<Generator>TextTemplatingFileGenerator</Generator>
</None>
当我运行自定义工具来重新生成 SQL(我需要经常这样做)时,PreDeploy 标记被删除,而 Build 标记被放置在它的位置。像这样:
<Build Include="Migration\PreDeployScript.sql">
<DependentUpon>Migration\PreDeployScript.tt</DependentUpon>
</Build>
它破坏了项目,我需要手动将 Build 改回 PreDeploy。
可以在模板文件中指定某些内容以始终保留构建操作 PreDeploy 吗?
谢谢!
【问题讨论】:
标签: sql-server visual-studio t4 sql-server-data-tools