首页 > 解决方案 > 如何调用向导添加新的项目模板

问题描述

我有一个通过向导生成的项目模板。现在我想通过同一个向导添加一个新的项目模板。添加新项目模板时如何调用向导。

例子:

添加到项目模板[添加到项目模板]

向导/表格[向导/表格]

添加新的项目模板[添加新的项目模板]

显示向导模板[显示向导模板]

显示新的项目/类[显示新项目/类别]

项目模板代码:

<VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Item">
  <TemplateData>
    <DefaultName>class1.cs</DefaultName>
    <Name>Myproject class1</Name>
    <Description>Myproject Class</Description>
    <ProjectType>CSharp</ProjectType>
    <SortOrder>10</SortOrder>
    <Icon>Myprojectclass1.png</Icon>
  </TemplateData>
  <TemplateContent>
    <References>
      <Reference>
        <Assembly>System</Assembly>
      </Reference>
      <Reference>
        <Assembly>System.Linq</Assembly>
      </Reference>
      <Reference>
        <Assembly>System.Threading.Tasks</Assembly>
      </Reference>
    </References>
    <ProjectItem SubType="Code" TargetFileName="$fileinputname$.cs" ReplaceParameters="true">class1.cs</ProjectItem>
    <CustomParameters>  
        <CustomParameter Name="$username$" Value="$safeitemrootname$"/> 
        <CustomParameter Name="$rootnamespace$" Value="$safeitemrootname$"/>
        <CustomParameter Name="$registeredorganization$" Value="$safeitemrootname$"/>
    </CustomParameters>  
  </TemplateContent>
    <WizardExtension>
    <Assembly>MyProjectWizard, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=f7a1fcb8d457e160</Assembly>
    <FullClassName>MyProjectWizard.WizardImplementation</FullClassName>
  </WizardExtension>
</VSTemplate>

标签: c#visual-studiowizardvsixitemtemplate

解决方案


我已经找到了解决方案,没有key.snk没有其他方法可以调用模板项。

因为当我调用 itemtemplate 时,我必须实现我的项目,我选择了创建的项目,唯一的方法是通过 key.snk。

如果他们有不同的表格,请回答这个问题,我想知道是否有更多方法可以调用 Item 模板。


推荐阅读