Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shared project with T4 template

I am big fan of shared projects and I want to use T4 templates similarly: reference shared project in different solutions and get access to generated content without hassle.

How to make T4 templates work in shared projects?

like image 801
Sinatr Avatar asked Apr 26 '16 07:04

Sinatr


1 Answers

So far the easiest way to organize it is to link .tt files:

  • Move all templates into separate shared project;
  • Do not reference this shared project! This is important and this is why previous step is essential. When shared project is referenced it's not possible to link its files!
  • Link .tt files from it (drag them with Alt key into target project or use Add - Existing item - Open - combo option "As link").
  • Now you should be able to set their Custom Tool property (in file options) as TextTemplatingFileGenerator in target project (which is not possible in shared project and the reason of all troubles).

Seems to work, though it's not really uses shared project feature. Shared project is only used as a container for .tt files (any other project will do, but shared project doesn't produce output, so it's better imho) which are linked to target project.

like image 164
Sinatr Avatar answered Nov 08 '22 19:11

Sinatr