ligershark / sidewafflev2

Other
30 stars 11 forks source link

Q: Template Creation Dialog #44

Closed grahamehorner closed 4 years ago

grahamehorner commented 4 years ago

I'm reviewing/researching the new templating engine for creating a set of templates that accept user/developer input similar to the aspnetcore templates; I'm confused to how/what is require and if sidewafflev2 can do this? also if/how/what I need to do to create a compatible vsix and weather vs-2017.host.json, *.vstemplate and/or other file are needed in the .template.config folder.

It would be great if you could share any help/guide references

thanks in advance.

sayedihashimi commented 4 years ago

If you have parameters that the user needs to specify, you will need to create a custom wizard that presents a UI and then passes those as parameters to the other wizards. In the .vstemplate this new wizard should be placed above the other wizards. I think I have a sample of this somewhere, I will look for it. Regarding the host file, if you put that next to your template.json file, it should be picked up and included in the .nupkg/.vsix. You don’t need a host file but template.json is required.

sayedihashimi commented 4 years ago

Here is the sample I was talking about https://github.com/sayedihashimi/sayed-samples/tree/master/dotnet-templates/PassParameterFromWizard. Specifically the wizard is at https://github.com/sayedihashimi/sayed-samples/blob/master/dotnet-templates/PassParameterFromWizard/VsixProject1/SayedWizard.cs and it’s declared in the .vstemplate at https://github.com/sayedihashimi/sayed-samples/blob/master/dotnet-templates/PassParameterFromWizard/Sayed.Console01/.template.config/template.vstemplate. In the wizard you’ll need to prefix the parameter name with “passthrough:” see https://github.com/sayedihashimi/sayed-samples/blob/813dbaf03d82c9c52f560666619d4f1cb648b9a5/dotnet-templates/PassParameterFromWizard/VsixProject1/SayedWizard.cs#L24

Let me know if you have more Qs.

grahamehorner commented 4 years ago

many thanks for the quick reply links and samples, much appreciated.

I do have other questions around structure of the generated solution, ie how the place projects into folders such as src or tests etc. ? I'm not sure if I'm doing something incorrect but projects don't seem to go into folders or solution folders.

sayedihashimi commented 4 years ago

The projects will be laid out in disk as they are in the template. To make a sln folder you’ll need to do that in a wizard. I think it’s easiest to add this wizard to run last and it should do the following:

grahamehorner commented 4 years ago

@sayedihashimi I'm trying to run the samples and/or add the custom dialog to the vsix/template.json as shown in the samples; however keep getting the error below

Capture

any ideas ?

sayedihashimi commented 4 years ago

I’ve never heard of DXC.Foundation.Template, I believe that’s not related to the sample. I will try it tomorrow, but I’m pretty sure that is some issue on the machine that you’re using.

grahamehorner commented 4 years ago

Sorry, DXC.Foundation.Template is my own assembly; pasted wrong screenshot, doh! but I get the same error with the sample expect with a different component name.

sayedihashimi commented 4 years ago

@grahamehorner can you paste the error you're getting when running the sample w/o modifications?

grahamehorner commented 4 years ago

@sayedihashimi apologies I got this to work, it was an issue with my signing cert

sayedihashimi commented 4 years ago

Happy to hear you got it working. If your template is open source please share a link.

grahamehorner commented 4 years ago

@sayedihashimi I would be happy to share, however I need to check with my employer and/or the client for which we are developing these templates on weather they would be happy to publish these given the number of additional closed source nugets that are referenced.

sayedihashimi commented 4 years ago

@grahamehorner no problem, if you have some proprietary stuff there then it's best to keep it private :) If it was OSS then I would take a look to see what you're working on.