简体   繁体   English

如何使用向导在Visual Studio 2017中添加项目模板

[英]how to add item template in visual studio 2017 using Wizard

Description: I'm developing a solution in which I'll call a template item with the form I want it to add. 说明:我正在开发一种解决方案,在该解决方案中,我将使用要添加的表单来调用模板项。

And I wonder if this is the best solution to use or has another method. 我想知道这是不是最好的解决方案,还是有另一种方法。

我的项目 my project 我的项目

Code: calss1.vstemplate 代码:calss1.vstemplate

 <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>
        //Call my Form
        <WizardExtension>
        <Assembly>MyProjectWizard, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=f7a1fcb8d457e160</Assembly>
        <FullClassName>MyProjectWizard.WizardImplementation</FullClassName>
      </WizardExtension>
    </VSTemplate>

Is this method valid? 这种方法有效吗? Is there another method? 还有其他方法吗?

I created a new method to call the item template using the "WizardRunKind". 我创建了一个新方法来使用“ WizardRunKind”调用项目模板。

This is the code I created: 这是我创建的代码:

    public void RunStarted(object automationObject,
    Dictionary<string, string> replacementsDictionary,
    WizardRunKind runKind, object[] customParams)
{
    if (runKind.HasFlag(WizardRunKind.AsNewItem))
    {
        inputForm = new MyProjectModulo();
        inputForm.ShowDialog();

    }

Note: Just call the item with the key.snk 注意:只需使用key.snk调用该项目

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何调用向导添加新的项模板 - How call a wizard to add new Item Template Microsoft Bot应用程序模板在Visual Studio 2017中不可见。如何添加Bot应用程序模板? - Microsoft bot application template is not visible in Visual studio 2017. How to add bot application template? 如何在 Visual Studio 2017 中添加服务引用 - How to add service reference in visual studio 2017 将自定义项模板添加到 Visual Studio 解决方案 - Add custom Item Template to Visual Studio Solution Visual Studio项目向导-参考SignalR程序集 - Visual Studio Item Wizard - Reference SignalR assembly 如何在 Visual Studio 2017 中使用 gRPC 模板? - How can I use the gRPC template in Visual Studio 2017? 如何创建Visual Studio 2017多模板VSIX项目? - How to create Visual Studio 2017 multi template VSIX project? 如何在Visual Studio中通过加载项添加jscript或html项目模板 - How to add a jscript or html item template via an add-in in visual studio 使用Visual Studio 2017的新csproj格式如何添加对较旧可移植库的支持? - Using the new csproj format for Visual Studio 2017 how to add support for the older portable libraries? 未检测到Visual Studio 2017中的新类项目 - New Class Item in Visual Studio 2017 not detected
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM