T4MVC is a fantastic solution to avoid 'Magic Strings' in ASP.NET MVC.
Thanks to David Ebbo for this contribution which has made its way to MVCContrib.
Must keep T4 template open and save it once.
This has been the only negative thing about the template. I thought about writing an Add-In for VS to do this and even taked to David about doing it. Well, his latest post has inspired me to write one. I took my dot net less plug in and ripped nearly everything out of it, threw in about 5 lines of new code and it is done.
Configuration
There isn't any. Just install the add-in and it should work. It watches for any save, add, or remove event to the solution and runs the T4 template at that time. As long as you have the T4MVC.tt file in your project it will run.
Source
I have attached the source and binaries. I am sure there are some improvements we all can make.
Installation
Simply download the file and double click to install into your Visual Studio Add-in folder. Currently I only have tested this for VS2008, however should be easy to make work on 2010. Full Source
What do you think?
7 comments:
Very nice, thanks!
Works brilliantly, thanks. The old method hadn't caused me any real problems but this is much better. Nice
thanks, would've been even easier with a .vsi(x) file tough
@Carl,
Good idea. Done...download link is now a .vsi file.
Has anyone tested in vs2010?
To make work in VS2010, just change the version in the .AddIn XML file from 9.0 to 10.
The add-in requires Full Trust, so it will die with "The add-in T4MVCAddIn.AddIn failed to load or caused an exception. Would you like to remove this add-in? {full UNC path} Error number 8013150a" if your VS2008 Addins folder is on a UNC. A workaround is here: http://forum.huagati.com/topic49-load-error-8013150a-if-userprofile-is-a-unc-path.aspx This isn't really the fault of Addin, but an environment issue.
Post a Comment