Get Visual Studio to run a T4 Template on every build

后端 未结 22 2745
余生分开走
余生分开走 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:09

    Hey, my script can also parse output extension

    for /r %1 %%f in (*.tt) do (
     for /f "tokens=3,4 delims==, " %%a in (%%f) do (
      if %%~a==extension "%CommonProgramFiles%\Microsoft Shared\TextTemplating\1.2\texttransform.exe" -out %%~pnf.%%~b -P %%~pf -P "%ProgramFiles%\Reference Assemblies\Microsoft\Framework\v3.5" %%f
     )
    )
    echo Exit Code = %ERRORLEVEL%
    

    Just create transform_all.bat $(SolutionDir) pre-build event, and all *.tt files in your solution will be transformed automaticaly.

提交回复
热议问题