How do I convince VS2008 to run .tt template files?

Following the step-by-step description of the word-one-syllable, I should get my demo app, right? But I have dropped twice so far and I am only step 4 in a 5 step process :(

1 Create a new project in Visual Studio 2008

Done that, yayy!

2 Add a connection string to your Web / App.config, give it a name and point it in a valid database

Done that, yayy!

3 Take the folder containing T4 templates ("tt" extensions) and find a folder called "_Settings". Open it in Notepad and set the ConnectionStringName to the name of the connection string you just made.

Oops. There is no name "_Settings.tt" - it's called "Settings.ttinclude" - is this the one I need to change? Do I also need to change my name?

So I take the punt and edit it to use the connection string name and database name and namespace name and save it as "_Settings.tt"

4 Drop the T4 templates folder into your project. Visual Studio 2008 will see them and execute the template code by creating classes

I drag the folder to VS2008 ConsoleApplication1 project and nothing happens.

All the docs and all of this suggests that VS2008 will magically understand the .tt extension and immediately trigger an action to do some serious work on my behalf.

I would wait, but Hell can freeze over, so I'm looking for clues. No, everyone thinks it's automatic, touch-free, magic.

5 You are done - go with Kabob.

No kebab for me. I'm not done yet. I need help.

+2


source to share


6 answers


right click and "run custom tool"



Are you using express? I read a post this morning moaning about how to use t4s in VS expres subsonic ... to set it up here SubSonic ASP.NET MVC sample in Visual Web Developer Express

+1


source


Try adding a new empty TT file to your project - VS should automatically link the "TextTemplatingFileGenerator" tool to the file. Open the original TT in a text editor (or VS) and cut and paste the content into an empty TT.

Or you can go to the Properties window for your TT file and set the Custom Tool property to TextTemplatingFileGenerator.



This should provide the "Run Custom Tool" option on the file's context menu.

And - you cannot have a link to the file - the TT file must be in the Project folder. Not sure why, but I can't get it to work otherwise.

+1


source


I'm really screwed.

Vista (Ultimate) spends 25 minutes on the installation DVD and then announces "Can't install Visual Studio 2008 SP1".

My guess is that I have installed something that interferes with not only the way VS2008 works, but also the way the installer works, so it cannot be repaired. Asshole!

I dug up the old hard drive image from the backup, ever since I was still using XP Pro. This one has VS2008 installed, but I didn't want to rollback Vista, so I booted it up on my old computer (after all).

Now .tt files are magically recognized and VS processes them and generates C # code - yayy!

But that's not all good news ...

The old PC is a donkey. It takes age to process .tt files and everything else is too slow too. I need to get my main Vista machine back on track, but at least now I can see the process working.

The next cabble is the mismatch between the screencast and what's going on in the .zip file ...

0


source


make sure your solution / project is "asp.net mvc" or "ClassLibrary" for VS to recognize .tt

0


source


See I can't drag files to Solution Explorer

basically you cannot drag and drop files in Visual Studio if you are using it as an administrator. Since Windows Explorer cannot be launched as administrator, the only way is to not launch Visual STudio as administrator, which will allow you to drag and drop files into Visual Studio.

0


source


I have the same frustration on Windows 7 and VS 2010 (works as Admin). There is no kabob for me either. I tried to run my own tool, which Jack Diddy also does. My proj is a class library.

0


source







All Articles