3

With T4 can you have custom code blocks, that should not be overwritten at generation? Like PreserveExistingFile but for a block of code in the generated file. I can’t use partial class in my scenario

Rodrigo Juarez
  • 1,745
  • 1
  • 23
  • 38
  • 1
    I also had the same scenario.. My TT generate the app config file. which has two or more than two section. I used MessageBox. there which prompts the user "Do you want to overwrite the ". I can click YES or NO. – Deepak Sharma Sep 30 '15 at 10:41

1 Answers1

2

There's no way to do this. You should either include unmodifiable code blocks in the template itself, or read them from another file.

Athari
  • 33,702
  • 16
  • 105
  • 146
  • Where in the process of generating the output should I read another file? I was thinking about reading the previous generated file and extract the custom blocks – Rodrigo Juarez Dec 31 '10 at 21:28
  • Alternatively, just use an <#@ include file=foo" #> directive to include the handwritten pieces. – GarethJ Dec 31 '10 at 23:06