How to create "Multi Project Template With Custom Wizard" in Visual Studio 2017
Asked Answered
H

2

7

I'm looking for help on making a multi project template (i.e. a deploy-able solution that contains multiple projects) with a custom wizard (to enable custom parameters to be entered).

I've followed "How to: Create Multi-Project Templates" to make the multi project template. This is working.

I've followed "How to: Use Wizards with Project Templates" to make my wizard in my VSIX files. This is working.

However, I can't get them to work together. I can either deploy my multi project template without a wizard OR I can get all of my individual project templates to show in the project gallery, via my VSIX file, with a working custom wizard.

Any ideas on how to combine the two methods?

Holmann answered 26/9, 2017 at 18:48 Comment(0)
H
5

I was able to adopt an answer from this blog.

The key is to package all of your exported projects (which come in ZIP which you have to extract) and your root .vstemplate file into a ZIP. This ZIP then needs to be an imported project template in your VSIX project.

Lastly, your wizard needs to be its own separate project you can reference in any of your individual project templates or in your VSIX. I had my wizard being created in my VSIX which just didn't seem to work.

Holmann answered 28/9, 2017 at 14:28 Comment(0)
M
1

As stated by Dan, you need to have your multi-project templates in a zip file.

However, you do not need to have the wizard code in a separate project, you can have it all in your VSIX project.

I your VSIX project, to add a reference to your .zip file, open your source.extension.vsixmanifest designer -> Assets -> New -> Select type Project Template and Source 'File on filesystem' and select your zip file. Make sure to also add your VSIX project as Assembly if you haven't already: New -> Select type Assembly and Source 'a project in current solution' and select your VSIX project. (This is probably why it didn't work for Dan)

In your multi-template.vstemplate file you need to add a reference to the VSIX dll as described in "How to: Use Wizards with Project Templates" using <WizardExtension>

In addition you can also add a <CustomParameters> section inside <TemplateContent> if you want to set up default custom parameter values. See here for more info: "The registration elements for customizing the template wizard"

Example:

<CustomParameters>
  <CustomParameter Name="$mycustomparameter1$" Value="value1"/>
  <CustomParameter Name="$mycustomparameter2$" Value="value2"/>
</CustomParameters>
Mikael answered 27/5, 2021 at 6:58 Comment(2)
Thank you. After countless tries to connect wizard I finally found your answer and wizard was connected.Sicilia
Good to hear it was helpful. BTW, I made a Visual Studio extension to help with all the leg work of setting up multi-template projects. marketplace.visualstudio.com/… for VS2022 and marketplace.visualstudio.com/… for VS2019Mikael

© 2022 - 2024 — McMap. All rights reserved.