This project is read-only.

Can't get the files to generate

Aug 12, 2009 at 4:42 PM
Edited Aug 12, 2009 at 4:50 PM

I am running visual studio 2008 on a 64 bit processor machine. I installed the T4 toolbox and T4 editor.

I created the "multiple file template" and ran the first time and got the 'Template' not a type in namespace error. So I excluded the TextTemplatingFileGenerator for custom tool in properties and left it blank. I reran and nothing gets ran. Can someone give me some guidance on as to what I'm doing incorrectly?

 

Thanks in advance.

Aug 12, 2009 at 5:04 PM
Edited Aug 12, 2009 at 5:06 PM

chief --

It is probably a problem with the template in that case.

Turn debugging on and the look at the errors if there are any.

To turn on debugging, see the tutorials linked the home page of this project at CodePlex.

 If that does not work, then build one of the basic samples in the tutorial-- that is what I did and it helped me understand things, and then I just changed the sample bit by bit to do what I wanted.

 HTH.

Thank you.

-- Mark Kamoski

 

Aug 12, 2009 at 5:22 PM

Thank you. I don't see any errors and the debugger is not getting hit.

I think after I removed the custom tool from the properties the template is getting completely ignored and not getting transformed by anything. A question I have that doesn't have much documentation on it the include file="T4Toolbox.tt", how does vs 2008 know where to grab this file if its not included in the project?

Aug 12, 2009 at 5:34 PM
Chief --

Regarding this...

>>>I think after I removed the custom tool from the properties the template is getting completely ignored and not getting transformed by anything

...make sure it works fine BEFORE moving the reusable parts of the template set into another project...

...I have not had time to get full step-through debugging working in templates (which I think is possible but I am not sure), and I cannot seem to get Debug.WriteLine() to work everywhere I want in a template set, so I code-in-the-dark and make very small refactorings to my templates and test after each and that seems to work as a development approach for me.

Regarding this...

>>>how does vs 2008 know where to grab this file if its not included in the project?

...I use absolute paths and that works like a charm...

...and it is said that one can use relative paths along with a one-time Registry tweak...

...see this link for details...

http://www.olegsych.com/2008/10/t4-tutorial-reusing-code-generators-on-multiple-projects/

HTH.

Thank you.

-- Mark Kamoski
Aug 12, 2009 at 5:35 PM

Thanks for the speedy response. WIll try shortly and report back.

Aug 12, 2009 at 6:59 PM

CHEERS!!

Figured this brat out.

 

Problem was in the template example:

Changed the :

GeneratedTextTransformation.Template

to

Template

 

Thanks Mark for your help with everything.

Oct 26, 2009 at 3:29 PM

I having a problem that is similar. I installed the T4Toolbox and added a new item to my project of type Generator. The file's custom tool property is blank, so when I edit and save the file nothing happens. Changing the custom tool to TextTemplatingFileGenerator gives the following error:

Compiling transformation: 'Microsoft.VisualStudio.TextTemplating.........GeneratedTextTransformation.SampleTemplate.RenderCore(): no suitable method found to override.

 

Comping transformation: 'Microsoft.VisualStudio.TextTemplating.....GeneratedTextTransformation.SampleTemplate' does not implement inherited abstract member 'Microsoft....TransformText()'. The template text is from Oleg's blog on generating multiple files in separate folders:

 

"

<#@ template language="C#" hostSpecific="true" debug="true" #>

<#@ output extension="txt" #>

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

<#

SampleTemplate template = new SampleTemplate();

template.Output.File = @"NewFolder1\outputfile.txt";

template.Output.Project = @"..\Project2\Project2.csproj";

template.RenderCore();

#>

<#+

public class SampleTemplate : Template

{

protected override void RenderCore()

{

this.WriteLine("Hello, World!");

}

}

#>"

Oct 26, 2009 at 10:22 PM

Build 9.10 introduced a breaking change (http://www.olegsych.com/2009/10/t4-toolbox-support-for-visual-studio-2010/) - RenderCore was replaced by TransformText. I haven't had a chance to update the tutorial articles yet.

Oct 27, 2009 at 2:10 AM
Does one need VS.NET 2010 to use the new T4Toolbox?
>
Oct 27, 2009 at 11:42 AM

No, 2008 should work.