0

I am using a T4 template with T4 Toolbox within Visual Studio 2012 to generate about 100 files and add them to the project. I have two templates, one of which outputs a .cs file, the other outputs a corresponding .designer.cs. Naming it this way seems to automatically assign the <DependentUpon> property in the .csproj file. (Is this a VS2012 feature? Or T4Toolbox?)

The generation itself only takes a couple of seconds. However, there is a long pause of about 3 minutes where Visual Studio is hogging the CPU during this time. Is there any way I can avoid this long pause?

My template looks something like this

<#@ template language="C#" debug="false" #>
<#@ output extension="txt" #>
<#@ assembly name="System.Core" #>
// imports ommitted...
<#@ assembly name="T4Toolbox.dll"#>
<#@ include file="T4Toolbox.tt" #>
<#       
    // about 100 files
    var filenames = MyHelper.GetFilenamesToProcess();

    // for each input file, generate two output files
    foreach(string filename in filenames)
    {      
       var mainPartTemplate = new MainPartTemplate();
       mainPartTemplate.RenderToFile(fileName + ".cs");

       var designerPartTemplate = new DesignerPartTemplate();
       designerPartTemplate.RenderToFile(fileName + ".designer.cs");        
    }

    // Beep so I can hear when the script finishes.
    Console.Beep(); 
    // It takes about two seconds to get here, then there is a 3 minute wait while 
    // Visual Studio is unresponsive.
#>

If I change the extension .designer.cs to anything else then there is no delay after the script runs, but the <DependentUpon> tag is then missing so the files are separated in the solution explorer and the View in Designer option is not available when right-clicking.

shamp00
  • 11,106
  • 4
  • 38
  • 81
  • Only thing that I know works fast is drag and drop from the explorer, but I don't know for sure if it works for dependent files or if it is fast for such combination. I know for sure in 2010 it works faster for single files. – Silvermind May 17 '13 at 15:28
  • are you using a build server? if so I can think of some work-arounds. Also, try closing your toolbox panel. There has been a number of reports of that thing causing slowdowns even when minimized. So not just minimizing it, closing it. – Maslow Sep 28 '13 at 02:37

0 Answers0