You should be able to add an IWizard
reference to the template, this will run when you click ok in the File -> Add window. You'll need to add the assembly and type to the vstemplate file.
Implement the RunFinished
or possibly the ProjectItemFinishedGenerating
method. You can then use the EnvDTE
object exposed by Visual Studio to manipulate any item in the solution using the standard Visual Studio Extensibility model..
The following code snippit (from the open source T4 Toolbox) shows how to set this property.
/// <summary>
/// Sets the known properties for the <see cref="ProjectItem"/> to be added to solution.
/// </summary>
/// <param name="projectItem">
/// A <see cref="ProjectItem"/> that represents the generated item in the solution.
/// </param>
/// <param name="output">
/// An <see cref="OutputFile"/> that holds metadata about the <see cref="ProjectItem"/> to be added to the solution.
/// </param>
private static void SetProjectItemProperties(ProjectItem projectItem, OutputFile output)
{
// Set "Build Action" property
if (!string.IsNullOrEmpty(output.BuildAction))
{
ICollection<string> buildActions = GetAvailableBuildActions(projectItem);
if (!buildActions.Contains(output.BuildAction))
{
throw new TransformationException(
string.Format(CultureInfo.CurrentCulture, "Build Action {0} is not supported for {1}", output.BuildAction, projectItem.Name));
}
SetPropertyValue(projectItem, "ItemType", output.BuildAction);
}
// Set "Copy to Output Directory" property
if (output.CopyToOutputDirectory != default(CopyToOutputDirectory))
{
SetPropertyValue(projectItem, "CopyToOutputDirectory", (int)output.CopyToOutputDirectory);
}
// Set "Custom Tool" property
if (!string.IsNullOrEmpty(output.CustomTool))
{
SetPropertyValue(projectItem, "CustomTool", output.CustomTool);
}
// Set "Custom Tool Namespace" property
if (!string.IsNullOrEmpty(output.CustomToolNamespace))
{
SetPropertyValue(projectItem, "CustomToolNamespace", output.CustomToolNamespace);
}
}