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;
}