sidewafflev2 icon indicating copy to clipboard operation
sidewafflev2 copied to clipboard

Wizard implementation via VSIX to deploy template.json

Open namtar1447 opened this issue 7 years ago • 4 comments

Hello,

Not sure how to go about sharing my question, feel free to enlighten me on how best to get the answer I need.

I've been working on a multi-project template.json and fine-tuning/testing using the dotnet new CLI. I now want to allow other developers to benefit from this and started wrapping it in a VSIX starting from the Template Pack Project Template. Deployment of the template works fine in the experimental instance.

Now, my template.json references a dozen or so symbols I would need to define when creating the project, so I started looking into doing an IWizard, discovered the joys of Windows Forms along the way, and now I've got all my parameters in memory ready to be used ... but can't find how to take those parameters and pass them to VS to do the equivalent of passing them as CLI parameters of 'dotnet new'.

Are there any alternatives to a Wizard to do what I need? Is this even the right place to post?

Thanks a ton for your help.

namtar1447 avatar Jan 22 '18 21:01 namtar1447

Hi @namtar1447, since you are wanting to show a UI or collect info from the user in Visual Studio, you'll need to create a custom wizard. You can do this with Win Forms or WPF.

sayedihashimi avatar Mar 26 '18 05:03 sayedihashimi

Thank you for the answer. Yes, the Wizard works, basically I just am unable to pass in the symbols. Here's an example:

"symbols": {
    "shortServiceName": {
      "isRequired": true,
      "type": "parameter",
      "datatype": "text",
      "description": "Short service name with no punctuation or spaces to be used in class names i.e. EnpCatalogImporter",
      "replaces": "ShortServiceName",
      "fileRename": "ShortServiceName"
    }
}

I would typically just use the command-line parameters when calling dotnet new, but I can't find an equivalent way to do this when the wizard is invoked this way.

<WizardExtension>
    <Assembly>MpcExtensions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=82b0b51e56c4f5a1</Assembly>
    <FullClassName>MpcExtensions.SolutionTemplates.MpcWindowsServiceWizard</FullClassName>
  </WizardExtension>
  <WizardExtension>
    <Assembly>Microsoft.VisualStudio.TemplateEngine.Wizard, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</Assembly>
    <FullClassName>Microsoft.VisualStudio.TemplateEngine.Wizard.TemplateEngineWizard</FullClassName>
  </WizardExtension>

Am I supposed to be able to use CustomerParameters in a specific way to do so?

namtar1447 avatar Mar 26 '18 13:03 namtar1447

There is a special syntax to indicate that the parameter should be passed through, take a look at my sample. Specifically this line.

sayedihashimi avatar Mar 26 '18 14:03 sayedihashimi

@namtar1447 Did the solution above solve your problem?

codewithtyler avatar May 27 '18 12:05 codewithtyler