I've built a t4 template to output multiple files, but I need these files to be embedded content.
Does t4 offer an out-of-the-box method of doing this?
If not, might it be possible to modify the project file by switching each file's <Content> element to an <EmbeddedResource> element?
Here's how I set a
ProjectItemto be an embedded resource: In the T4 template I have a function which takes theProjectobject and aFileInfoobject representing the T4 template itself - there may be a simpler method but I obtained the templateFileInfousing...The template
FileInfois used because we need the generated files (my T4 template outputs multiple files) which are generated 'under' the template file in the solution.[Really, what I want here is a
ProjectItemrepresenting the template, so that I can loop over the auto-generated children. If there's a better way of doing this, please comment.]Once I have the
ProjectItemobjects representing each of the T4-generated files, I enumerate eachPropertiescollection until I find the"BuildAction"property for thatProjectItem; this is then set as "Embedded Resource" using a constant.