Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The T4 templating that comes with Visual Studio 2008 natively or with Visual Studio 2005 SDK, you can pretty much generate anything you want.</p> <p>You can have more info on the following links:</p> <ul> <li><a href="http://www.hanselman.com/blog/T4TextTemplateTransformationToolkitCodeGenerationBestKeptVisualStudioSecret.aspx" rel="nofollow noreferrer">Scott Hanselman's Blog</a> </li> <li><a href="http://blog.wekeroad.com/blog/make-visual-studio-generate-your-repository/" rel="nofollow noreferrer">Rob Conery's Blog</a> </li> <li><a href="http://www.olegsych.com/" rel="nofollow noreferrer">Oleg Sych's Blog</a> which is an entire repository of T4 examples</li> <li><a href="http://weblogs.asp.net/jdanforth/archive/2008/04/23/t4-support-in-vs2008.aspx" rel="nofollow noreferrer">Johan Danforth's Blog</a></li> </ul> <p>I'm pretty sure that all those links is a good start to your quest.</p> <p>If you want to generate T4 templates outside of Visual Studio, there is custom MSBuild task to invoke a T4 template (<a href="http://geekswithblogs.net/EltonStoneman/archive/2008/07/25/an-msbuild-task-to-execute-t4-templates.aspx" rel="nofollow noreferrer">link</a>)</p> <p>Here is a sample of the "Execute" code of the MSBuild task. <a href="http://www.sixeyed.com/fileDrop/code/MSBuild/Sixeyed.MSBuild/Sixeyed.MSBuild/Tasks/CodeGen/ExecuteT4Template.cs" rel="nofollow noreferrer">Click here for the source code</a>:</p> <pre><code>public override bool Execute() { bool success = false; //read in the template: string template = File.ReadAllText(this.TemplatePath); //replace tags with property and item group values: ProjectHelper helper = new ProjectHelper(this); template = helper.ResolveProjectItems(template); //copy the template to a temp file: this._tempFilePath = Path.GetTempFileName(); File.WriteAllText(this._tempFilePath, template); //shell out to the exe: ProcessHelper.Run(this, TextTransform.ToolPath, TextTransform.ExeName, string.Format(TextTransform.ArgumentFormat, this.OutputPath, this._tempFilePath)); success = true; return success; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload