public virtual void GenerateTemplate(EnvDTE.ProjectItem templateItem) { var masterProjectItem = this.Dte.Solution.FindProjectItem(this.TemplateFile); string fullOutputPath; if (templateItem.IsLinkedItem()) { fullOutputPath = Path.Combine(templateItem.ContainingProject.GetProjectDir(), templateItem.GetVirtualPath()); } else { fullOutputPath = templateItem.GetFullPath(); } fullOutputPath = fullOutputPath.Replace(templateItem.GetFileNameExtension(), ".{ext}"); this.GenerateTemplateInternal(templateItem.GetFullPath(), fullOutputPath, masterProjectItem, templateItem); }