Last week, I blogged about a nice way of auto-running T4MVC by using the Macro IDE to write an OnBuildBegin event handler. This was a big improvement over the hacky ‘AlwaysKeepTemplateDirty’ flag that we’ve been using since T4MVC’s early days.
Since then, Wayne Brantley has taken this idea to the next level by turning it into a Visual Studio AddIn. Check out his post and give it a try!
The nice benefits of the AddIn over directly handling VS events in the macro IDE are:
Note that Wayne’s AddIn works a bit differently from Joachim’s macro (and from AlwaysKeepTemplateDirty): instead of running when you build the project, it runs as soon as you save a file. The advantage is that you can just Add a controller action and save the .cs file, and it will instantly be available to your views via T4MVC.
The downside is that it makes saving a little slower, but in practice it seems to be mostly negligible. But it would be great to hear people’s feedback on this. If there is a perf issue, we have some ideas on making it faster.
If you use T4MVC, please give this AddIn a try and let us know how it works for you!