Get Visual Studio to run a T4 Template on every build

后端 未结 22 2417
余生分开走
余生分开走 2020-11-22 08:29

How do I get a T4 template to generate its output on every build? As it is now, it only regenerates it when I make a change to the template.

I have found other ques

22条回答
  •  情深已故
    2020-11-22 09:07

    In Visual Studio 2017 (probably next versions too), you should add this in Pre-build event:

    "$(DevEnvDir)TextTransform.exe" -out "$(ProjectDir)YourTemplate.cs" "$(ProjectDir)YourTemplate.tt"
    

    p.s. Change path to your template if it's located not in root project directory.

提交回复
热议问题