Shared project with T4 template
Asked Answered
F

1

6

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?

Fouquiertinville answered 26/4, 2016 at 7:17 Comment(0)
F
8

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.

Fouquiertinville answered 26/4, 2016 at 8:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.