VsTemplate:TemplateGroupID的用法

时间:2013-01-25 13:37:18

标签: visual-studio-2012 vs-extensibility visual-studio-templates

无论我使用HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\11.0\Projects\中的哪个ID,都不会有效!当我将ShowByDefault设置为false时,“添加新项”窗口中不会显示任何内容。 在我的示例中,我使用SharePointItemTemplateGroupID,但Web也不起作用。我不知道我做错了什么。

我* .vstemplate:

<?xml version="1.0" encoding="utf-8"?>
<VSTemplate Version="3.0.0" Type="Item" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" xmlns:sdk="http://schemas.microsoft.com/developer/vstemplate-sdkextension/2010">
  <TemplateData>
    <Name>My User Control</Name>
    <Description>My User Control with My-specific content.</Description>
    <Icon>MyUserControl.ico</Icon>
    <TemplateID>b83fe377-e03a-40a8-9366-a04988fae2a7</TemplateID>
    <ProjectType>CSharp</ProjectType>
    <SortOrder>1</SortOrder>
    <RequiredFrameworkVersion>2.0</RequiredFrameworkVersion>
    <NumberOfParentCategoriesToRollUp>1</NumberOfParentCategoriesToRollUp>
    <DefaultName>MyUserControl.ascx</DefaultName>
    <TemplateGroupID>SharePointItemTemplateGroupID</TemplateGroupID>
    <ProjectSubType>SharePointItemTemplateGroupID</ProjectSubType>
    <ShowByDefault>true</ShowByDefault>
  </TemplateData>
  <TemplateContent>
    <References>
      <Reference>
        <Assembly>Microsoft.SharePoint</Assembly>
      </Reference>
      <Reference>
        <Assembly>System</Assembly>
      </Reference>
      <Reference>
        <Assembly>System.Web</Assembly>
      </Reference>
    </References>
    <ProjectItem ReplaceParameters="true" TargetFileName="$fileinputname$.$fileinputextension$">MyUserControl.ascx</ProjectItem>
    <ProjectItem ReplaceParameters="true" TargetFileName="$fileinputname$.$fileinputextension$.cs">MyUserControl.ascx.cs</ProjectItem>
    <ProjectItem ReplaceParameters="true" TargetFileName="$fileinputname$.$fileinputextension$.designer.cs">MyUserControl.ascx.designer.cs</ProjectItem>
    <CustomParameters>
      <CustomParameter Name="MappedFolderType" Value="UserControl" />
      <CustomParameter Name="$UC$" Value="UserControl" />
      <CustomParameter Name="$baseclass$" Value="UserControl"/>
    </CustomParameters>
  </TemplateContent>
  <WizardExtension>
    <Assembly>Microsoft.VisualStudio.SharePoint.ProjectExtensions.Wizards, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</Assembly>
    <FullClassName>Microsoft.VisualStudio.SharePoint.ProjectExtensions.Wizards.GenericMappedFolderWizard</FullClassName>
  </WizardExtension>
</VSTemplate>

1 个答案:

答案 0 :(得分:0)

我不知道注册表项,但如果您希望项目模板显示在“新建项目”对话框的某个文件夹中,请将其放在文件系统上的相应文件夹中。例如,将压缩的模板文件放在此处:

C:\Users\<yourusername>\Documents\Visual Studio 2012\Templates\ProjectTemplates\CSharp\SharePoint\

CSharp文件夹是语言文件夹,因此请替换Visual Basic或您需要的任何语言。此外,上述路径中不存在SharePoint文件夹,因此您必须创建它。此文件夹的内容将与已安装的文件夹合并:

\VisualStudioInstallationDirectory\Common7\IDE\ProjectTemplates\

请参阅MSDN