I want to use t4 to generate some text at runtime. I created a 'Runtime Text Template'. I noticed that there is a .cs file that is generated from the .tt file. I'm trying to figure out if that is normally checked into source control. Normally I don't check in generated file. This file has a #line
directive with a full path to the file on my local machine. Checking that in just seems funny, since it obviously won't be the same on my teammate's machine.
Your concern about the filename in the .cs file is very valid but in this case it's part of a #line
compiler directive and it simply tells the compiler what filename to print in it's output when processing this file.
Edit: Nice find from the OP - For VS 2012 you can add the following directive in your template to remove LinePragmas. Further SO discussion here.
<#@ template language="C#" linePragmas="false" #>
As a general rule I only like to have files checked in if they...
- Are needed by another developer or build agent to build the code
- Get deployed
- Serve as documentation or some similar purpose
Yes you will want to check it in to source code because it will most likely cause the build to break for other developers if you don't. Although they could just run the T4 template themselves it shouldn't be up to them to do so. Another related reason why is if you have some sort of build tool, like cruise control, it may not run your T4 template and wont be able to build the project anymore.
© 2022 - 2024 — McMap. All rights reserved.