Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check-in t4 class into source control?

Tags:

c#

t4

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.

like image 789
Kyle Avatar asked Mar 19 '23 22:03

Kyle


2 Answers

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

  1. Are needed by another developer or build agent to build the code
  2. Get deployed
  3. Serve as documentation or some similar purpose
like image 111
Kevin Avatar answered Mar 22 '23 11:03

Kevin


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.

like image 24
Letseatlunch Avatar answered Mar 22 '23 13:03

Letseatlunch