Transforming DSL Setup T4 templates from the command line


With DSL Tools, we supply a tool called TextTransform.exe to run the T4 text templating engine from the command line.

This is useful for creating batch builds or bulk transformation scripts.

However, it needs a lot of parameters to get it to run, because it needs the context of where to load various directive processors from.  Consequently, the best practice is to call it from a small batch script.

We supply one of these scripts with the DSL Tools, called DslTextTransform.cmd.  This wrapper calls the exe with the right parameters to transform the templates used to build a DSL itself (remember, we use a DSL as dogfood to build DSLs)

It also provides a neat example for you to create wrapper scripts for your own DSLs.

However, out of the box, DslTextTransform doesn't allow you to transform the templates used to create WiX files as part of bulding a DSL setup project.  You need a few more parameters yet.  We can't put this one in out of the box as it needs soem data that's specific to your project.

Here's a sample command line that should work for Visual Studio 2005 for a solution with the standard project names of Dsl and DslPackage in a directory "d:\\dev\\test\\ORIPEUndo" for a debug build.

DslTextTransform.cmd Main.tt -dp "InstallerDefinitionDirectiveProcessor!Microsoft.VisualStudio.Modeling.Deployment.InstallerDefinitionDirectiveProcessor!Microsoft.VisualStudio.Modeling.Sdk.Deployment, Version=8.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"  -a "InstallerDefinitionDirectiveProcessor!!Projects!Dsl|DslPackage" -a InstallerDefinitionDirectiveProcessor!!Dsl:OutputPath!d:\\dev\\test\\ORIPEUndo\\Dsl\\bin\\Debug\\ -a InstallerDefinitionDirectiveProcessor!!DslPackage:OutputPath!d:\\dev\\test\\ORIPEUndo\\DslPackage\\bin\\Debug\\

The first parameter supplies which projects can be referenced from the model and then the second  and third supply the output paths where assemblies can be found for those projects.  This is the information that T4 would get automatically from the IDE if it was running inside Visual Studio.  Note the quotes around the list of projects as they're separated with a vertical bar which otherwise is interpreted as a pipe character.

For Visual Studio 2008 Beta 2, just flip 8.2 to 9.0

Also in Visual Studio 2008, we support arbitrary project nesting in solution folders, in which case you might replace "Dsl" with "Foo/bar/baz/Dsl".

 

Comments (2)

  1. TeraBIThia says:

    Es posible usar las plantillas de texto de visual studio (t4) directamente desde la línea de comandos

  2. Bits and pieces of stuff about passing parameters to T4: Oleg Sych on Understanding T4: <#@ property

Skip to main content