生成的文件(由T4生成)被重置为“生成" [英] Generated (by T4) file Build Action gets reset to Build

查看:95
本文介绍了生成的文件(由T4生成)被重置为“生成"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在Visual Studio 2013中有一个数据库项目.在此项目中,我们有一个.tt文件,该文件生成.sql脚本.问题是生成后,生成文件的生成操作会自动设置为Build.如果我们手动将其更改为无",则在重新生成(运行自定义工具)后,它将重置为构建".

We have a database project in Visual Studio 2013. In this project we have a .tt file which generates .sql script. The problem is after generation the build action of the generated file is automatically set to Build. If we change it manually to None, it gets reset to Build after regenerating (running custom tool).

另一个奇怪的事情是,仅当.tt文件在数据库项目中以及该项目的某个文件夹中(而不是在根目录中)时,它才会发生.如果.tt文件位于另一个项目(任何地方)或数据库项目的根目录中,则生成的文件的生成操作在重新生成后不会更改.

Another strange thing is that it only happens if .tt file is in database project and in some folder of that project (not in root). if .tt file is in another project (anywhere) or in the root of the database project, the build action of the generated file does not change after regeneration.

我们没有任何Visual Studio加载项,我试图禁用所有可能被禁用的扩展和更新.

We don't have any Visual Studio add-ins and I tried to disable all extensions and updates which could be disabled.

如有需要,我会为您提供详细信息.

I will give you any details if needed.

推荐答案

此答案已在评论中提及,但有人可能会漏掉它.将输出扩展名更改为".sqlscript"和默认的构建操作"将为无".

This answer was kind of mentioned in comments, but someone might miss it. Changed output extension to e.g. ".sqlscript" and default Build Action will be None.

<#@ output extension=".sqlscript" #>

您还可以将此扩展程序的默认编辑器更改为

You can also change default editor for this extension to

"Microsoft SQL Server数据工具,T-SQL编辑器"

"Microsoft SQL Server Data Tools, T-SQL Editor"

,因此您可以阅读和编辑它作为标准的T-SQL脚本.只需

so you can read and edit it as standard T-SQL script. Just go to

工具->选项.->文本编辑器->文件扩展名.

Tools -> Options.. -> Text Editor -> File Extensions.

它不能解决".sql"文件的问题,但这是一个很好的解决方法,对我来说很好.我在VS2015中进行了测试,但它在VS2013中的工作方式可能相似.

It does not solve the problem with ".sql" files, but it is a good workaround and works fine for me. I tested it in VS2015 but it probably works similar in VS2013.

这篇关于生成的文件(由T4生成)被重置为“生成"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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