Hi Oleg
Again thanks for your response. I did see this in GAT documentation but didn't think it would help me. I also read your article which was very helpful in further understanding T4.
My problem is that the project does not exist at the point where I am trying to use the T4 template. In your article, you talk about selecting templates from the "Add New Item" dialog box for an open / new project.
Using GAT I can create a recipe which will perform actions to transform the T4 template and use the generated code to create a class file, when a user selects a "template" from the "Add New Item" dialog box for an open / new project.
However, in my scenario, I have a recipe which is unfolding a solution and the related project is part of the solution. As that project unfolds, I want to use T4 to generate a class file (in the given project) based on the arguments available in my recipe. I assumed I would be able to simply include a reference to the T4 template in my project vstemplate e.g.
<VSTemplate Version="2.0.0" Type="Project" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
<TemplateData>
<Name>Sample Project</Name>
<Description>Sample project</Description>
<Icon Package="{FAE04EC1-301F-11d3-BF4B-00C04F79EFBC}" ID="4547" />
<ProjectType>CSharp</ProjectType>
<SortOrder>20</SortOrder>
<CreateNewFolder>false</CreateNewFolder>
<DefaultName>SampleClass</DefaultName>
<ProvideDefaultName>true</ProvideDefaultName>
</TemplateData>
<TemplateContent>
<Project File="SampleProject.csproj" ReplaceParameters="true" TargetFileName="SampleProject.csproj">
<ProjectItem ReplaceParameters="true" TargetFileName="$TargetFileName$">SampleClass.cs.t4</ProjectItem> </Project>
</TemplateContent>
where SampleClass.cs.t4 is a T4 template that resides in the same directory as the vstemplate. However, I believe I'm missing something in my understanding:
Either:
a) This is simply not possible and I should use standard project item templates
or
b) I need some way of calling action(s) prior to the project being created to transform the T4 template and create the class to be generated, which can then be included as the project unfolds.
In your example above from the GAT documentation, it is possible to call a recipe from an
Item Template, however in my scenario as the arguments I want to use are already available to the vstemplate file (as the recipe has already been invoked), I don't want to actually do this.
<
WizardData
>
<
Template
xmlns
=
"
http://schemas.microsoft.com/pag/gax-template
"
SchemaVersion
=
"
1.0
"
Recipe
=
"
CreateT4Item
"
>
</
Template
>
</
WizardData
>
Any ideas / thoughts would be appreciated ... Thanks