visual studio 2013 - Create VS2013 item templates for multiple files in multiple folders -
i started item template, if that's not appropriate solution, please let me know. i'm trying automate creation of several files (and possible several folders) when new widget added project. i'm using mvp pattern, each widget gets 5 classes (imodel, model, iview, view, , presenter), each of them same base name in different folders. folder structure like
+models +interfaces + imodelone + modelone + subsetone + interfaces + imodelthree + modelthree +views + interfaces + iviewone + subsetone + interfaces + iviewthree + viewthree +presenters + presenterone + subsetone + presenterthree the models, views, , presenters folders have same structure. i'd way add new items template in same structure, based on either 1.) clicked add menu item (e.g., if right clicked on presenters->subsetone , selected add new item, somehow realize subsetone "base path" structure from?), or 2.) allow user input "base path" via wizard-type thing.
without using wizard, can create of necessary files @ top levels of models, views, , presenters folders (or hard-coded subdirectory). ok widgets (those need @ top level), use limited.
i followed instructions @ http://msdn.microsoft.com/en-us/library/ms185301.aspx set up. problem when trying use wizard, pops message indicating "value not fall within expected range." tried debugging via steps @ http://social.msdn.microsoft.com/forums/vstudio/en-us/005df602-5b22-4a33-b03c-df6cf9f97715/step-by-step-instruction-how-to-debug-a-custom-wizard-template-needed?forum=vsx, breakpoint never hit, says symbols aren't loaded. message box in wizard class never gets shown, though, suspect error isn't in wizard class. if can working on machine, i'd able give other developers on team use well.
my wizard class code:
/// <summary> /// wizard class receive additional input /// user before creating set of mvp classes. /// </summary> public class mvpwizard : iwizard { /// <summary> /// runs custom wizard logic @ beginning of template wizard run. /// </summary> /// <param name="automationobject">the automation object being used template /// wizard.</param> /// <param name="replacementsdictionary">the list of standard parameters replaced.</param> /// <param name="runkind">a <see cref="t:microsoft.visualstudio.templatewizard.wizardrunkind"/> indicating /// type of wizard run.</param><param name="customparams">the custom parameters /// perform parameter replacement in project.</param> public void runstarted(object automationobject, dictionary<string, string> replacementsdictionary, wizardrunkind runkind, object[] customparams) { mvpwizardform form = new mvpwizardform(); try { form.showdialog(); replacementsdictionary.add("$basepath$", form.basepath); replacementsdictionary.add("$presenterpath$", form.presenterpath); } catch (exception e) { messagebox.show("an exception occured: ", e.message); } } /// <summary> /// runs custom wizard logic when project has finished generating. /// </summary> /// <param name="project">the project finished generating.</param> public void projectfinishedgenerating(project project) {} /// <summary> /// runs custom wizard logic when project item has finished generating. /// </summary> /// <param name="projectitem">the project item finished generating.</param> public void projectitemfinishedgenerating(projectitem projectitem) {} /// <summary> /// indicates whether specified project item should added project. /// </summary> /// <returns> /// true if project item should added project; otherwise, false. /// </returns> /// <param name="filepath">the path project item.</param> public bool shouldaddprojectitem(string filepath) { return true; } /// <summary> /// runs custom wizard logic before opening item in template. /// </summary> /// <param name="projectitem">the project item opened.</param> public void beforeopeningfile(projectitem projectitem) {} /// <summary> /// runs custom wizard logic when wizard has completed tasks. /// </summary> public void runfinished() {} and .vstemplate code:
<vstemplate version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" type="item"> <templatedata> <defaultname>mvp.cs</defaultname> <name>mvp item</name> <description>stuff</description> <projecttype>csharp</projecttype> <sortorder>10</sortorder> <icon>__templateicon.png</icon> </templatedata> <templatecontent> <references /> <projectitem subtype="" targetfilename="models/interfaces/i$fileinputname$model.cs" replaceparameters="true">itestmodel.cs</projectitem> <projectitem subtype="" targetfilename="models/$fileinputname$model.cs" replaceparameters="true">testmodel.cs</projectitem> <projectitem subtype="" targetfilename="views/interfaces/i$fileinputname$view.cs" replaceparameters="true">itestview.cs</projectitem> <projectitem subtype="" targetfilename="views/$fileinputname$view.cs" replaceparameters="true">testview.cs</projectitem> <projectitem subtype="" targetfilename="views/$fileinputname$view.designer.cs" replaceparameters="true">testview.designer.cs</projectitem> <projectitem subtype="" targetfilename="presenters/$fileinputname$presenter.cs" replaceparameters="true">testpresenter.cs</projectitem> <customparameters> <customparameter name="$model$" value="$fileinputname$model"/> <customparameter name="$modelinterface$" value="i$fileinputname$model"/> <customparameter name="$presenter$" value="$fileinputname$presenter"/> <customparameter name="$view$" value="$fileinputname$view"/> <customparameter name="$viewinterface$" value="i$fileinputname$view"/> </customparameters> </templatecontent> <wizardextension> <assembly>mvpwizard, version=1.0.0.0, culture=neutral, publickeytoken=37d8d03713727225</assembly> <fullclassname>mvpwizard.mvpwizard</fullclassname> </wizardextension> </vstemplate> any ideas? tia!
this article provide option create template contains folder structure well.
Comments
Post a Comment