Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3800348
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T13:52:44+00:00 2026-05-19T13:52:44+00:00

I have a T4 that is generating multiple .html files. After creating them all

  • 0

I have a T4 that is generating multiple .html files.

After creating them all it then deletes them. I have seen the files create in both explorer and VS2010 ultimate (the solution explorer bar grows and then shrinks right back).

I have modified Oleg Synch’s updated multiple output code as follows:

ProjectItem GetTemplateItem(DTE dte)
{
 return   // Find the .tt file's ProjectItem
 dte.Solution.FindProjectItem(Host.TemplateFile);
}

void SaveOutput(string outputFileName,List<string> savedOutputs)
 {
  string templateDirectory = Path.GetDirectoryName(Host.TemplateFile);
  string outputFilePath = Path.Combine(templateDirectory, outputFileName);  
  var text= this.GenerationEnvironment.ToString();
  WriteDiagnosticLine("Writing:"+text.Length+" characters");
  File.WriteAllText(outputFilePath,text);
  this.GenerationEnvironment = new StringBuilder();  

  ProjectItem templateProjectItem = GetTemplateItem(Dte);

  templateProjectItem.ProjectItems.AddFromFile(outputFilePath);  

  savedOutputs.Add(outputFileName);

  WriteDiagnosticLine("Added:"+outputFileName);
 }

void WriteDiagnosticLine(string line)
{
System.Diagnostics.Debug.WriteLine(line);
}

the initial code to set Dte is

bool AlwaysKeepTemplateDirty = true;
DTE Dte;
var serviceProvider = Host as IServiceProvider;

    if (serviceProvider != null) {
        Dte = serviceProvider.GetService(typeof(SDTE)) as DTE;
    }

    // Fail if we couldn't get the DTE. This can happen when trying to run in TextTransform.exe
    if (Dte == null) {
        throw new Exception("T4Generator can only execute through the Visual Studio host");
    }

it happens whether I make a change and hit save, or right click the .tt file and say run custom tool.

In case it’s helpful here’s my tt declaration:

<#@ template language="C#" hostspecific="True" debug="True" #>
<#@ output extension=".txt" #>
<#@ assembly name="System.Core" #>
<#@ assembly name="System.Xml" #>
<#@ assembly name="Microsoft.VisualStudio.Shell.Interop.8.0" #>
<#@ assembly name="EnvDTE" #>
<#@ assembly name="EnvDTE80" #>
<#@ import namespace="System.IO" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Text.RegularExpressions" #>
<#@ import namespace="Microsoft.VisualStudio.Shell.Interop" #>
<#@ import namespace="EnvDTE" #>
<#@ import namespace="EnvDTE80" #>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T13:52:45+00:00Added an answer on May 19, 2026 at 1:52 pm

    removing

    <#@ include file="T4Toolbox.tt" #>
    

    seems to have solved it. pretty bizarre.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very simple stored procedure which returns multiple record sets. All of
I'm dynamically generating datepicker's by simply appending the field HTML to a div: <input
I have a list of ints that I want to join into a string
I have a caret delimited (key=value) input and would like to extract multiple tokens
First, the background. I used to have a collection logs and used map/reduce to
I am busy building a custom webpart with various textboxes and lookup fields. All
I am looking to setup architecture for entity framework that will break apart the
I've been playing around with hosting on discountasp.net and am in the process of
This might be a super easy answer, since I'm sure it's not uncommon. I
Given an Entity Data Model (EDMX) with Code Generation Strategy set to None, how

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.