Is it possible to make a T4 template output to be merged with an existing file?
For example, if a T4 template generates localization resource XML files, is it possible to merge them in some existing resource file?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can get access to the underlying string builder the the T4 uses thought the GenerationEnvironment property. So by adding something like the following to your T4 you should be able to get a workable solution;
If you want to stop the default backing file from getting updated you can set GenerationEnvironment to a new string builder after you save the contents to stop anything being output.