4

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.

Pic 1

Once you select that option click on Next and provide all the details like Project name, Location, Solution Name and click on "Create".

Here you get new options to create different types of web applications like Empty, Web Forms etc like the below screen shot.

Pic 2

A similar kind of project template, I'm trying to create to provide multiple solutions that users can 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".

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.

What I really need is to add a project template with multiple types of solution options, not just multiple projects.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • If anyone has any idea please let me know if that's even possible. – Rahul Khandelwal Nov 22 '21 at 04:45
  • 1
    AFAIK you'll need to build your own GUI from scratch as a VSIX (in addition to your templates). It's a lot of effort for-not-much result. Why do you want to do this anyway? – Dai Nov 22 '21 at 04:46
  • We have 7-8 different types of solutions that we want our employees to use. So instead of showing 7-8 custom templates on the startup page, we want to show only one and then as per requirement employees can select. – Rahul Khandelwal Nov 22 '21 at 04:56
  • If it's just 7 or 8 then just have them as separate top-level template options, otherwise it's a waste of effort, imo. – Dai Nov 22 '21 at 05:10
  • As of now, it's 7-8 but we are expecting it to be increasing in the future that's why we are looking to club it based on their type. – Rahul Khandelwal Nov 22 '21 at 05:24
  • @RahulKhandelwal: Did you ever get this sorted out? I would like to do something similar and don't want to have one wizard for every project-type of ours... – Kai Adelmann May 10 '22 at 09:37

1 Answers1

1

Unfortunately, this is not a built-in feature of visual studio when exporting project templates just by themselves. As Dai said, you will have to create a VSIX project that has a custom wizard UI with project templates. You can do this in either C# or 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.

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:

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

Abob
  • 751
  • 5
  • 27