Hey all,
I was excited to get going with SubSonic 3, but soon realized that website projects do not support T4 files (Text Template Transformation Toolkit). I found that there is a command-line tool that you can use to generate the output, but I wanted something even easier. So I set out to create a right-click context menu item to generate the code files. This is one way for how you can do it.
- Add an external tool command to the command-line tool
- Click Tools -> External Tools…
- Click Add
Title: Generate T4 Code
Command: C:Program FilesCommon FilesMicrosoft SharedTextTemplating1.2TextTransform.exe
Arguments: $(ItemFileName)$(ItemExt) -out $(ItemFileName).cs
Initial Directory: $(ItemDir) - Check "Use Output Window" and click Ok
- Add it to the website project context menu
- Click View -> Toolbars -> Customize…
- Check Context Menus
- With the Customize dialog still open, click the Tools menu
- While holding Ctrl, left click and drag your External Tool command to the Project and Solution Context Menus toolbar, which opens allowing you to continue dragging the external command it to Web Item
- Click the Project and Solution Context Menus toolbar, Click Web Item, and Right Click External Command
- Change the Name to Generate T4 Code and click enter
- Close the Customize dialog
- Now you have a right click context menu to generate code for .tt files
There is an annoyance with this method, however. The context menu item will show up regardless of file type/extension. If someone knows how to fix this, or has a better way of adding context menu items, I’m all ears. I did find this article for how to add context menu items with VSIP, but that seemed a bit overkill…
RE: Visual Studio Website Project: Add context menu for T4 files
As I mentioned in my previous post , I am playing around with SubSonic 3 . While the templates that come with it are a good starting point, I made some changes to make things feel a little more like the SubSonic I know and love… You can download my