Use T4 Templates For XSLT Transformation

Suppose you have XSLT style sheets that produce some code from XML files. Now suppose you want to integrate these style sheets into your Visual Studio solution to generate code artefacts. You could call command line tools from the pre-build event to process the XSLT files. Alternatively, you could somehow bring the XSLT markup into a T4 template and let the regular Visual Studio integration initiate execution of the template. That is actually not that difficult, but there is one major obstacle.Read More »

Resolve Visual Studio Macros In VSIX Packages Or T4 Templates

We all love Visual Studio Macros, right? Pre- and Post-Build actions or MSBuild scripts would get very nasty if there were no macros like “ProjectDir”, “ConfigurationName” or “OutDir”. If these macros are so useful, then why not make use of them in your own VSIX packages or T4 templates? If your answer is “because I got lost in the maze of Visual Studio’s object model and it’s too dark to see” then fear not! You will find your way out very soon. Read More »

Inheriting a T4 Template and Calling EnvDTE.DTE: The System Cannot Find The File Specified

Some strange behavior occurred today when I tried to encapsulate some functionality of a T4 template into a base class. The base class should load the Visual Studio automation object (DTE), but that led to an error stating that “the system cannot find the file specified”. “the file” was the assembly that contains my base class – i.e. the assembly that was currently running. So what’s going on here? Read More »