I am writing a Guidance Package that is for an architecture similar to CAB - there is a shell and it can load modules. The solution has a folder called Modules and I want a recipe that can create a module in this solution folder. Say the developer wants a module called "ClientModule" the recipe will create another solution folder under Modules called "ClientModule" and under this sub-folder create 2 projects: One called "ClientModule" and one called "ClientModulePublisher".
To do this I looked at the SCSF guidance package and "butchered" my own version of theirUnfoldModuleProjectAction action. This action is pretty straight-forward: create the solution folder and then call the "AddFromTemplate" method on the solution folder.
The problem comes in with substitution of $parameters$ in the template file. For the module project, I have a class called Module.cs with a placeholder called $ModuleName$. No matter how I try to do it, the parameter is never substituted for the actual ModuleName value (this is a RecipeArgument). This works for the SCSF package, but I cannot get it to work for my template, though I cannot see any differences.
So I tried to turn the VSTemplate into a T4 template. The template is really nothing fancy and has only 1 property (for substitution) declared as follows:
<#@
property processor="PropertyProcessor" name="ModuleName" #>Then I tried to call the TextTemplateAction from code to do the rendering as follows:
using (TextTemplateAction action = new TextTemplateAction())
{
Site.Container.Add(action);
action.Template = classTemplate;
action.Execute();
return action.Content;
}
This failed when the Execute() method was called - the exception said that property "ModuleName" had not been supplied.
However, if I use the recipe to call the T4 transform, it works perfectly. The Action looks as follows:
<Action Name="RenderModuleClass" Type="TextTemplateAction" Template="Text\Module.cs.t4">
<Input Name="ModuleName" RecipeArgument="ModuleName" />
<Output Name="Content"/>
</Action>
The question is, how can I call the TextTemplateAction from the code? Am I missing something that "initializes" the dictionary that the rendering engine uses (incidentally, if I use GetService<IDictionary>() to get the dictionary service, the ModuleName is there).
Any ideas?
Project Manager - Real People