I have successfully created (and manually edited) an Item Template that will add a number of files in one 'shot'. I want these files to all be created under a folder that should be created at the same time.
In Project Template .vstemplate files I can specify a Folder element, but the schema does not allow one in the Item Template.
Any know if this is possible or do I have to start looking at extending the IDE also?
From within the folder click on the folder or the drop down arrow beside it. Click the "Save as Template" button to save this folder structure as a folder template.
By default, templates installed with Visual Studio are located in: %ProgramFiles(x86)%\Microsoft Visual Studio\2019\<edition>\Common7\IDE\ProjectTemplates\<Language>\<Locale ID> %ProgramFiles(x86)%\Microsoft Visual Studio\2019\<edition>\Common7\IDE\ItemTemplates\<Language>\<Locale ID>
Adding folders#The File > Add Folder to Workspace command brings up an Open Folder dialog to select the new folder. Once a root folder is added, the Explorer will show the new folder as a root in the File Explorer. You can right-click on any of the root folders and use the context menu to add or remove folders.
I figured it out! You just need to edit the TargetFileName attribute of the ProjectItem element and suggest a fullpath...
<ProjectItem SubType="" TargetFileName="$fileinputname$\$fileinputname$.txt" ReplaceParameters="true">template.txt</ProjectItem>
In the above example if the user names the new item 'dog' VS will create a dog folder and copy the template.txt file as dog.txt into it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With