简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM