Getting and compiling T4 Toolbox source code

Update: This article has been updated to reflect changes made to support Visual Studio 2010.

Over the past year, several people have asked me to provide instructions on how to compile T4 Toolbox. The process is not difficult, but since I don’t do it every day, I have to dig through my email archive to find all the steps every time I need to provide the answer. This seems to be as good time as any to write everything down, so here it goes…

You will need latest versions of the following tools installed in order to compile T4 Toolbox.

If you want to build the help file for Visual Studio 2008, you will also need

Installing Tools

You can install most of the tools with default options.

  • When installing StyleCop, make sure that MSBuild integration files feature is installed.

StyleCop installation options

Accessing Source Code

You have two different ways of getting T4 Toolbox source code. If you have not been added to the list of developers,

Source Code page of T4 Toolbox project on Code Plex

  • After accepting the license agreement, you will be prompted to download a ZIP archive that contains the latest version of the T4 Toolbox source code. Save the file to your local hard drive first and unblock it before extracting the files. Unless you unblock the ZIP archive first, the Visual Studio will not “trust” it and you will get obscure security errors and warnings later on.

Unblock downloaded ZIP archive

  • Extract all files from this archive to a folder on your hard drive, such as C:\T4Toolbox, and open T4Toolbox.sln located in the Source subfolder.

T4 Toolbox source code on local hard drive

  • When Visual Studio opens T4 Toolbox solution for the first time, select the Load project normally option. T4Toolbox.csproj uses MSBuild extensions from SDC tasks and StyleCop, you will need to select this option in order to compile it.


At this point, you should be able to compile the T4 toolbox. Make changes until it works the way you need it and then upload the files you modified as a patch on CodePlex. Myself or someone else will take a look at the changes you’ve made and commit them to the main source code of the project.

Using Team Explorer

When you are regularly working on T4 Toolbox source code, having to download a source code snapshot becomes a hassle. When your CodePlex account has been added to the list of T4 Toolbox developers, you can start using Team Explorer from Visual Studio.

  • Download and install Team Explorer from here.
  • Once you have it installed, go to T4 Toolbox page on CodePlex, make sure you are logged (1), open the Source Code tab (2) and then click the Visual Studio Team Explorer link (3). On the right-hand side, you will see the information you will need to use in Team Explorer (4).

Team Explorer instructions

  • In Visual Studio, select View->Team Explorer from the main menu.
  • In Team Explorer, click Add Existing Team Project button
  • In the Connect to Team Foundation Server dialog, click Servers button
  • In the Add/Remove Team Foundation Server dialog, click Add button
  • In the Add Team Foundation Server dialog, enter server name, port number and protocol from the CodePlex page and click OK.

Add T4Toolbox Project to Team Explorer

  • Back in the Add/Remove Team Foundation Server dialog, click Close button
  • Back in the Connect to Team Foundation Server dialog, select T4Toolbox project and click OK button
  • Back in Team Explorer, you should now see the T4Toolbox project and its information.


  • Double-click the Source Control node to open Source Control Explorer

Source Control Explorer

  • In Source Control Explorer, select T4Toolbox folder on the left side and click the Not mapped link on the right.
  • In the Map dialog, enter name of the local folder you want to use for T4 Toolbox source code and click Map button.

Map workspace dialog

  • Back in Source Control Explorer, click Get Latest Version  button to download the source code to your local hard drive.
  • Once downloaded, double-click T4Toolbox.sln in the Source sub-folder to open the solution.

Get Latest Version and Open Solution from Source Control Explorer

At this point, you can check files out, change them and check them in. The source control functionality is similar to Visual SourceSafe and Subversion, so it should be familiar to most developers.

Compiling T4Toolbox.csproj

The T4Toolbox.csproj has been manually customized to target versions 3.5 and 4.0 of the .NET Framework from individual configurations. This was done in order to allow building T4 Toolbox binaries for Visual Studio 2008 and Visual Studio 2010 from the same code base. Unfortunately, you have to have separate sets of binaries for Visual Studio 2008 and 2010 because they use different extensibility and text templating assemblies. Some of these assemblies are not only compiled for different .NET framework versions but have different assembly names.

The project customization was done by manually editing the XML in the project file to define TargetFrameworkProperty in each configuration-specific property group instead of the global property group.

<PropertyGroup Condition=" ‘$(Configuration)|$(Platform)’ == ‘v3.5|x86′ ">

<PropertyGroup Condition=" ‘$(Configuration)|$(Platform)’ == ‘v4.0|x86′ ">

This allows us to define conditional references for platform-specific assemblies. For example, Microsoft.VisualStudio.TextTemplating assembly has to be referenced to compile T4Toolbox.dll for Visual Studio 2008 and Microsoft.VisualStudio.TextTemplating.10.0 has to be referenced to compile T4Toolbox.10.0.dll for Visual Studio 2010.

<Reference Include="Microsoft.VisualStudio.TextTemplating" Condition="‘$(TargetFrameworkVersion)’ == ‘v3.5′" />
<Reference Include="Microsoft.VisualStudio.TextTemplating.10.0" Condition="‘$(TargetFrameworkVersion)’ == ‘v4.0′"/>

This customization is not natively supported by Visual Studio, which displays warnings at design time about not being able to resolve assembly references.

Solution Explorer Error List

However, these warnings don’t affect the compilation of the project, which I typically do using the Batch Build option:


Conditional assembly references cannot be added using built-in Add Reference dialog in Visual Studio and have to be added directly to the project file using XML editor.

Write a Comment

Take a moment to comment and tell us what you think. Some basic HTML is allowed for formatting.

Reader Comments

Be the first to leave a comment!