T4 code generation without Visual Studio 2010?

Is it possible to start generating T4 code without having to use Visual Studio 2010? Basically, I need to build an ORM house (don’t ask ... if I had a choice that I wouldn’t make). I planned to use a subsonic base, but change some things and how they work. However, my main question is: can I start T4 from an external application that I am writing, so I can use the T4 functions? Or am I better off doing this myself (which I doubt)?

+4
source share
4 answers

TextTransform.exe will do what you want for simple scripts:

http://msdn.microsoft.com/en-us/library/bb126245.aspx

Here's how to run a T4 template from your own code for templates created in VS 2010:

http://msdn.microsoft.com/en-us/library/ee844259(VS.100).aspx

And here's how to run the T4 template from your own code for templates created in VS 2008:

http://www.capprime.com/software_development_weblog/PermaLink,guid,104d9faf-5780-42ca-88e5-c04cb88f61b3.aspx

There will be some problems running Subsonic T4 templates outside of Visual Studio:

How can I automate t4 code generation for SubSonic

I would stick with T4, not a roll of your own template engine.

+7
source

T4 is part of Visual Studio. If your ORM tool can assume that Visual Studio is available, T4 is a good choice. You have the option to redistribute the Visual Studio shell, which also includes T4, with your application. In addition, you can use pre-processed templates to compile templates into executable code generators. In compiled form, these templates do not require Visual Studio, but also cannot be changed.

Oleg

+3
source

AFAIK T4 templates are called from within the Visual Studio IDE.

Building ORM requires more than text templates. I suggest you study AtomWeaver (at http://www.atomweaver.com ), which is a code generator that allows you to create models from individual building blocks (called “atoms”). These atoms are smart templates that act like text templates, but also as mini-programs, allowing for a much simpler line replacement.

You can create your own “Atoms” that transform the database structure into source code. Then, for each new database, you combine these Atoms to build your schema and run the generator to get the source code. Since what you built is actually a model of your database, you can make any changes in the future and restore your code.

AtomWeaver implements ABSE, a kind of model-oriented software development (has nothing to do with UML or MDA). Learn ABSE mechanics at http://www.abse.info

AtomWeaver is currently in open beta. There is not much documentation at the moment, so it may not be easy for you to get up to speed with it.

0
source

There is a TextTransform.exe command line utility that you can use to generate code for the T4 template. I cannot comment on whether it is the right tool for creating ORMs, but it suits me well enough for creating machine states from an XML file.

http://msdn.microsoft.com/en-us/library/bb126245.aspx

0
source

All Articles