Visual Studio Development Bookmark and Share   
 index > Visual Studio Guidance Automation Toolkit > Call T4 Action
 

Call T4 Action

Hi, is there any way to call a TextTemplateAction from an Action. The problem is setting the value for the PropertyProcessors.

Thanks,

Martin
Mar77incho  Thursday, October 18, 2007 1:00 AM

That's why you have a reference to 8.2 TextTemplateHost and you should use 8.1 instead of that. Try change the reference to 8.1 and it should works.

hth

jose.

Jose Escrich  Friday, October 19, 2007 6:48 PM
Hi Martin,
You should write your own action using the host directly, here http://weblogs.asp.net/jescrich/archive/2007/05/03/testing-t4-templates-using-the-gax-host.aspx
you've an example how to invoke the TemplateHost and run the transformation,

hth.
jose.

Jose Escrich  Thursday, October 18, 2007 11:58 PM
Thanks for the info, it helped a lot but i have a problem when I execute the template:

string tempfile = Path.GetTempFileName();
string rutaTemplate = "";
TypeResolutionService typeResService = (TypeResolutionService)GetService(typeof(ITypeResolutionService));
Dictionary<string, PropertyData> dict = new Dictionary<string, PropertyData>();
dict.Add("ClassName", new PropertyData(modulo, typeof(string)));
dict.Add("ClassNameMin", new PropertyData(modulo.ToLower(), typeof(string)));
dict.Add("Namespace", new PropertyData("Tactics", typeof(string)));
dict.Add("Project", new PropertyData(projectPresenter, typeof(string)));
dict.Add("Suf", new PropertyData(sufijo, typeof(string)));
rutaTemplate = @"C:\Documents and Settings\Computer\Desktop\Codigo\TacticsConferenceSite\TacticsConferenceSite\Templates\Text\CrearModulePresenter.cs.t4";
TemplateHost host = new TemplateHost(Directory.GetCurrentDirectory(), dict);
host.TemplateFile = rutaTemplate;

ITextTemplatingEngine engine = new Engine();
string template = File.ReadAllText(host.TemplateFile);
string contenidoABMPresent = engine.ProcessTemplate(template, host);

using (StreamWriter sw = new StreamWriter(tempfile, false))
{
sw.WriteLine(contenidoABMPresent);
}
EnvDTE.ProjectItem item = CreateDirectoryPresenter();
item.ProjectItems.AddFromTemplate(tempfile, fileABMPresenter);
File.Delete(tempfile);

When I execute engine.ProcessTemplate the HOST parameter is not properly set, i get an exception "Entry Point Not Found". Which directory is it supposed to look in the first argument of new TemplateHost?

Thanks again,

Martin
Mar77incho  Friday, October 19, 2007 12:11 PM

That's why you have a reference to 8.2 TextTemplateHost and you should use 8.1 instead of that. Try change the reference to 8.1 and it should works.

hth

jose.

Jose Escrich  Friday, October 19, 2007 6:48 PM

You can use google to search for other answers

Custom Search

More Threads

• Can you detect all installed packages?
• Add as Link and name space
• Support for Web Application Project
• Parameterising ProjectType in VS2005 templates
• DAL
• How do you pass arguments from previous wizard pages
• Toolkit for GAX/GAT released!!
• Guidance Package Visual Studio 2005 Project Template not installed on Vista 5456
• Creating database projects
• How to validate dependencies from Setup Package