Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generated (by T4) file Build Action gets reset to Build

Tags:

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).

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.

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.

like image 320
nightcoder Avatar asked May 04 '15 19:05

nightcoder


1 Answers

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 Data Tools, T-SQL Editor"

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

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

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.

like image 194
Daniel Kozłowski Avatar answered Dec 21 '22 14:12

Daniel Kozłowski