/// <summary>
/// Based on the Template and TypeGuid properties of the
/// element, generate the full template path.
///
/// TypeGuid should be the Guid of a registered project factory.
/// Template can be a full path, a project template (for projects
/// that support VsTemplates) or a relative path (for other projects).
/// </summary>
protected virtual string GetProjectTemplatePath(ProjectElement element)
{
ProjectElement elementToUse = (element == null) ? this.nestedProjectElement : element;
if (elementToUse == null)
{
throw new ArgumentNullException("element");
}
string templateFile = elementToUse.GetMetadata(ProjectFileConstants.Template);
Debug.Assert(!String.IsNullOrEmpty(templateFile), "No template file has been specified in the template attribute in the project file");
string fullPath = templateFile;
if (!Path.IsPathRooted(templateFile))
{
RegisteredProjectType registeredProjectType = this.GetRegisteredProject(elementToUse);
// This is not a full path
Debug.Assert(registeredProjectType != null && (!String.IsNullOrEmpty(registeredProjectType.DefaultProjectExtensionValue) || !String.IsNullOrEmpty(registeredProjectType.WizardTemplatesDirValue)), " Registered wizard directory value not set in the registry.");
// See if this specify a VsTemplate file
fullPath = registeredProjectType.GetVSTemplateFile(templateFile);
if (String.IsNullOrEmpty(fullPath))
{
// Default to using the WizardTemplateDir to calculate the absolute path
fullPath = Path.Combine(registeredProjectType.WizardTemplatesDirValue, templateFile);
}
}
return(fullPath);
}