ligershark / sidewafflev2

Other
30 stars 11 forks source link

Wizard implementation via VSIX to deploy template.json #28

Open namtar1447 opened 6 years ago

namtar1447 commented 6 years ago

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.

sayedihashimi commented 6 years ago

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.

namtar1447 commented 6 years ago

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?

sayedihashimi commented 6 years ago

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

codewithtyler commented 6 years ago

@namtar1447 Did the solution above solve your problem?