How to add a dependency to a arbitrary file to a T4 template?

后端 未结 4 1044
甜味超标
甜味超标 2021-01-02 11:35

I have a T4 template that generates classes from an xml file.

How can I add a dependency between the xml file and the template file so that when the xml file is mod

4条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-02 12:11

    How long does the tool take to execute? One lazy option might be to simply edit the csproj such that it always runs the tool during build (presumably via or a custom targets file) - of course, this depends on it being quick to execute.

    Another way would be to write a shim that works as the "Custom Tool" in VS, and simply calls the existing exe (or whatever) with the right args. Not trivial, but doable (see here) - I believe this then supposedly plays fairly nicely with change detection. It is actually on my list of things to do for a current project, so I'll find out soon enough...

提交回复
热议问题