Catalin DICU
Catalin DICU

Reputation: 4638

Wix & T4 : no "Custom Tool" option

I want to generate a fragment using T4 but after adding a .tt file to the Wix project there is no "Custom Tool" option for this file. And there is no menu item "Run custom tool" when right clicking on the .tt file.

Is there a hack for this ? I'm using VS 2010 and latest Wix 3.5

Upvotes: 8

Views: 1263

Answers (4)

Cyanfish
Cyanfish

Reputation: 4153

If you have (or can create) another project in the same solution that does support T4 templates, there is a simple way to do it.

  1. Create the T4 template somewhere in that project
  2. In the WIX project, add the output file as a link (right click on project, Add Existing Item, Add As Link)

Upvotes: 1

Brian
Brian

Reputation: 7146

Using Gareth's suggestion of the T4 toolbox I was able to load in a T4 template, but it wasn't generating the file as expected.

What I ended up doing was creating a stub C# class project with my templates, and running a post-build command to copy the output to the WiX installer. Below is a working example.

WiX + T4 example

Here is a quick-and-dirty scripts that walks a folder structure and includes everything but whats in excluded files. It's at least a good starting point for adding files to your project on a folder-by-folder basis.

GetFiles.ttinclude - Utility methods to walk directory structure and maintain list of files

Files.tt - Generate WiX include

Upvotes: 1

GarethJ
GarethJ

Reputation: 6606

The Wix VS project system unfortunately doesn't support single file generators, so you won't get the default T4 experience.

You have a couple of choices. Oleg Sych's T4Toolbox has tools to run templates that target other projects, so you could run them in one project and target the output to your WiX project.

Alternatively, T4 has a simple service API STextTemplating. You could write a small VS add-in that does whatever generation you want in your Wix Project.

Upvotes: 3

Christopher Painter
Christopher Painter

Reputation: 55601

I've never used T4 let alone with WiX, but a google of it turns up several interesting hits including the last one asking what you are asking but no one ever knew the answer.

T4 template to generate Wix scripts to generate WCF MSIs in MSBuild

How to use MSBuild and Wix to create msi package...

[WiX-users] WiX 3.0 Support for T4 Templates in Visual Studio 2008]3

Upvotes: 1

Related Questions