Can I redistribute Microsoft T4 Engine with my product?

I am generating code dynamically, currently using String.Format and embedding placeholders. But reformatting C # code to use as a template is a pain, and I think using a T4 template would be better.

However, code generation will occur on a running system, so I need to know that I can safely and legally redistribute Microsoft T4 Engine with my product.

Has anyone else done this? Or find out the (legal) answer?

+6
c # t4
source share
7 answers

It looks like another option may be coming up soon.

Miguel de Icaza published information about T4 integration in MonoDevelop yesterday, so I expect you to get a mono-equivalent T4 toolkit at any time.

See: http://tirania.org/blog/archive/2009/Mar-10.html

+5
source share

You can redistribute T4 as part of DSLToolsRedist , however, it requires a standard version of Visual Studio 2005 or higher to install it. I do not believe that T4 can be legally redistributed without Visual Studio at this time. The script you described will be directly supported in Visual Studio 2010

+3
source share

I have an answer, and, unfortunately, this is not the way Oleg suggested. (Great work on T4, by the way, Oleg). You cannot redistribute T4 at this time - it is part of VS. In VS2010, it will be possible to precompile T4 templates and then redistribute these precompiled templates with your application, regardless of T4, to run them.

+2
source share

For clarity, the official answer is that you cannot distribute the Microsoft T4 engine as a separate fragment from Visual Studio.

However, with Visual Studio 2010, you can use and distribute pre-compiled templates that are not dependent on Visual Studio.

You can also use T4 outside of Visual Studio on the computer on which Visual Studio is installed.

You can also license and distribute the isolated Visual Studio isolated shell for free and use this as a host for your tools - it includes T4.

Starting with Visual Studio 2010 Service Pack 1 (SP1), you have a license to copy T4 to your build machine through the license in the buildserver.txt file in the VS installation directory.

+2
source share

I have my own template code generation system, compiling code in a separate application domain before VS2008 came out.

If you are interested, send a comment and I will send the URL.

The code for using my template engine is here , you can access it using a web browser or specify a Subversion client. Please note: the link that starts here does stop after the word, but the server side WMD renderer loses touch with the following text.

Please note that if you simply copy one file in this namespace, it will not compile on its own, it requires some things in LVK.Delegates and LVK.Scripting, namespaces raises a couple of levels from the link above. If you do not want to suck out the entire library, you will need to extract the pieces that it complains one at a time until it compiles.

There is also a binary version of the library in / LVK_3_5 / trunk / Binaries / Debug / LVK in the same repository.If you download it as easy as adding a link to it, and check the LVK.Text.Templates.TextTemplate class.

Unfortunately, I don't have examples for my library right now.

Basically, to use the template:

TextTemplate tt = new TextTemplate(); tt.Source = "... code here, check example file above ..."; tt.Compile(); String output = tt.Generate(singleObjectParameter); 

Inside the template, which is basically all the code that is inserted into one method (which means that it is not as good as T4, since it can easily add methods, but you can use anonymous methods), you will have access to the object data passed to it as a parameter named data.

So, to simply display the contents of the passed parameter:

 <%= data %> 

To repeat this:

 <% for (Int32 index = 0; index < 10; index++) { %> <%= data %> <% } %> 

If you have questions, send them to my email address at lasse@vkarlsen.no.

+1
source share

I remembered that it appeared in 2006 (before I knew what T4 was!) And went looking for it and found it http://social.msdn.microsoft.com/Forums/en-US/vsx/thread/ 1ab0bf3f-2810-4adf-bf75-900b98dee8e2 / Unfortunately the gotdotnet link is broken. It's hard to say that in this thread they agree that you can legally place T4 outside of VS and redistribute - or not.

0
source share

This is a real shame, but, as Oleg points out, if he is untested, how will you let him go.

Lasevk, of course, interests me - I thought about remaking the template engine that I build about 10 years ago, but I am always ready for an easier life!

0
source share

All Articles