Unfolding a new Dsl

In the RTM release of the Visualization and Modeling SDK, when we unfold a new designer, it really no time, and this is because you no longer need to wait for the text templates to be transformed.

If you look in the GeneratedCode folders of the Dsl or DlsPackage projects, you’ll see that the files contain this message:

 

Placeholder for content that will be generated when the solution is built for the first time

Now, if you have opened the Output Window, and build your DSL for the first time, you’ll see this:

------ Build started: Project: Dsl, Configuration: Debug Any CPU ------
  Transforming template GeneratedCode\SerializationHelper.tt...
  Transforming template GeneratedCode\ConnectionBuilders.tt...
  Transforming template GeneratedCode\Diagram.tt...
  Transforming template GeneratedCode\DirectiveProcessor.tt...
  Transforming template GeneratedCode\DomainRelationships.tt...
  Transforming template GeneratedCode\Connectors.tt...
  Transforming template GeneratedCode\DomainClasses.tt...
  Transforming template GeneratedCode\DomainModelResx.tt...
  Transforming template GeneratedCode\HelpKeywordHelper.tt...
  Transforming template GeneratedCode\MultiplicityValidation.tt...
  Transforming template GeneratedCode\PropertiesGrid.tt...
  Transforming template GeneratedCode\MyNewDesignerSchema.tt...
  Transforming template GeneratedCode\DomainModel.tt...
  Transforming template GeneratedCode\Serializer.tt...
  Transforming template GeneratedCode\Shapes.tt...
  Transforming template GeneratedCode\ToolboxHelper.tt...
  Dsl -> c:\users\demo\documents\visual studio 2010\Projects\MyNewDesigner\Dsl\bin\Debug\Company.MyNewDesigner.Dsl.dll
------ Build started: Project: DslPackage, Configuration: Debug Any CPU ------
  Transforming template source.extension.tt...
  Transforming template GeneratedCode\Constants.tt...
  Transforming template GeneratedCode\DocData.tt...
  Transforming template GeneratedCode\DocView.tt...
  Transforming template GeneratedCode\ModelExplorer.tt...
  Transforming template GeneratedCode\EditorFactory.tt...
  Transforming template GeneratedCode\ModelExplorerToolWindow.tt...
  Transforming template GeneratedCode\Package.tt...
  Transforming template GeneratedCode\CommandSet.tt...
  Transforming template GeneratedCode\GeneratedVSCT.tt...
  Transforming template ProjectItemTemplates\CSharp.tt...
  Transforming template ProjectItemTemplates\VisualBasic.tt...
  DslPackage ->
  DslPackage ->
  DslPackage -> c:\users\jmprieur.europe\documents\visual studio 2010\Projects\MyNewDesigner\DslPackage\bin\Debug\Company.MyNewDesigner.DslPackage.dll
  Creating intermediate PkgDef file.
  Creating VSIX Container...
  DslPackage -> c:\users\demo\documents\visual studio 2010\Projects\MyNewDesigner\DslPackage\bin\Debug\Company.MyNewDesigner.DslPackage.vsix
========== Build: 2 succeeded or up-to-date, 0 failed, 0 skipped ==========

 

You’ll note that the the text templates were expanded at build time.

Now, if you change the DslDefinition, you won’t need to press the “Transform All Templates” any longer in the solution explorer. Just build it.

 

How does it work?

Why is it so?

If to unload your Dsl.csproj (or DslPackage.csproj). You’ll discover the following lines.

<!-- Project specific properties to control T4/DSL targets -->

  <PropertyGroup>
  <TransformOnBuild>True</TransformOnBuild>
  </PropertyGroup>
  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
  <Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\DSLTools\v10.0\Microsoft.DSLTools.targets" />

 

We provided already T4-MsBuild in the VsVmSdk RC1, but this time, we have included the build rule in the DSL Tools targets.

 

 

More about T4-MsBuild

I was going to tell you more about T4-MsBuild, and will do in the future. But it turns out that, for the moment, Oleg has written a nice, introductory article about it: http://www.olegsych.com/2010/04/understanding-t4-msbuild-integration/.

Enjoy!