简体   繁体   English

如何在自定义模板 Visual Studio 2019 中添加多个选项

[英]How to add multiple options in custom template Visual Studio 2019

I want to add multiple options inside a custom project template.我想在自定义项目模板中添加多个选项。

For example when you create a new project search web and select ASP.NET Web Application as shown below screenshot.例如,当您创建一个新项目时,搜索 web 和 select ASP.NET ZC6E190B284633C48EZ ApplicationC30F4B76CE73B8DDZ ZC6E190B284633C48E39E5 如下图所示。

图一

Once you select that option click on Next and provide all the details like Project name, Location, Solution Name and click on "Create".一旦你 select 该选项单击下一步并提供所有详细信息,如项目名称、位置、解决方案名称,然后单击“创建”。

Here you get new options to create different types of web applications like Empty, Web Forms etc like the below screen shot.在这里,您可以获得创建不同类型的 web 应用程序的新选项,例如 Empty、Web Forms 等,如下面的屏幕截图。

图二

A similar kind of project template, I'm trying to create to provide multiple solutions that users can select.一种类似的项目模板,我正在尝试创建以提供多种解决方案,用户可以 select。

In my case, user will select "Custom Project" as the project template and inside that template, there should be different options like "Custom Utility", "Custom UI", "Custom Component".在我的例子中,用户将 select “自定义项目”作为项目模板,在该模板内,应该有不同的选项,如“自定义实用程序”、“自定义 UI”、“自定义组件”。

I went through different blogs and post about it but couldn't find anything on this topic.我浏览了不同的博客并发布了有关它的信息,但找不到有关此主题的任何内容。 Everywhere it's explained how to add a project template with multiple projects eg.到处都解释了如何添加具有多个项目的项目模板,例如。 this on Linkedin , this on C# corner or this on MSDN . 这个在 Linkedin 上这个在 C# 角落或者这个在MSDN上。

What I really need is to add a project template with multiple types of solution options, not just multiple projects.我真正需要的是添加具有多种解决方案选项的项目模板,而不仅仅是多个项目。

Unfortunately, this is not a built-in feature of visual studio when exporting project templates just by themselves.不幸的是,在单独导出项目模板时,这不是 Visual Studio 的内置功能。 As Dai said, you will have to create a VSIX project that has a custom wizard UI with project templates.正如 Dai 所说,您将必须创建一个 VSIX 项目,该项目具有带有项目模板的自定义向导 UI You can do this in either C# or Visual Basic.您可以在 C# 或 Visual Basic 中执行此操作。 Note that this would take a lot of work on your end because you would probably have to do the UI from scratch and do your best to replicate what visual studio is using with built-in templates, though the default styling on the windows controls should hopefully match.请注意,这将需要您完成大量工作,因为您可能必须从头开始制作 UI,并尽力复制 Visual Studio 使用内置模板使用的内容,尽管 windows 控件上的默认样式应该希望匹配。

Luckily, Microsoft has an official walkthrough on the docs on how to do this.幸运的是,微软有一个关于如何做到这一点的文档的官方演练 A key section is when they create the UserInputForm , which in your case would be the custom ui where the user can select the sub template:一个关键部分是他们创建UserInputForm时,在您的情况下将是自定义 ui,用户可以在其中 select 子模板:

public partial class UserSelectTemplateForm : Form
{
    public UserSelectTemplateForm ()
    {
        this.Controls.Add(...);
        //...
    }
    //...    
}

If you need additional help getting started you may also want to look at Microsoft's getting started with the VSIX project template docs如果您需要其他入门帮助,您可能还想查看 Microsoft 的VSIX 项目模板文档入门

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

相关问题 如何在 Visual Studio 2019 中添加 .mdf 文件? - How to add .mdf file in Visual Studio 2019? 适用于 Autocad 的 Visual Studio 2019 中的模板 - Template in Visual Studio 2019 for Autocad 无法添加自己的自定义 EFDataAcces 库 Visual Studio 2019 - Cannot add own custom EFDataAcces Library Visual studio 2019 Visual Studio 2019 - 无法将自定义管道 Object 添加到工具箱 SSIS - Visual Studio 2019 - Cannot add Custom Pipeline Object to Toolbox SSIS 将自定义项模板添加到 Visual Studio 解决方案 - Add custom Item Template to Visual Studio Solution 如何在 Visual Studio 2019 的一个内添加多个 forms? - How do I add multiple forms inside one on Visual Studio 2019? 无法在 Visual Studio 2019 Preview 和 Visual Studio 2019 中添加引用 - Unable to add references in Visual studio 2019 Preview and Visual Studio 2019 如何更改 vsix 中的自定义菜单(Visual Studio 2019) - How to change custom menu in your vsix (Visual Studio 2019) 如何将 .Net 框架添加到 Visual Studio preview 2019 项目 - How to add .Net framework to Visual Studio preview 2019 project 未显示 Visual Studio 2019 空白解决方案模板 - Visual Studio 2019 Blank Solution template is not showed
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM