I am looking to create a new Visual Studio 2012 element template that generates five files, three of which are attached, which is not the case. It should look like this:
MyView1.View MyView1.view.cs MyView1.data.cs MyView1.gen.cs MyView1.js
(The reason I need a separate JavaScript file is due to the problem of using it as a built-in resource for dynamic output for parsing at runtime.)
This is the template file I came up with so far:
<VSTemplate Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Item"> <TemplateData> <DefaultName>MyView.view</DefaultName> <Name>MVC Desktop View - Integration Test</Name> <Description>A view in a MVC-based desktop web application for use in integration tests.</Description> <ProjectType>CSharp</ProjectType> <SortOrder>10</SortOrder> <Icon>__TemplateIcon.ico</Icon> <NumberOfParentCategoriesToRollUp>1</NumberOfParentCategoriesToRollUp> </TemplateData> <TemplateContent> <ProjectItem TargetFileName="$fileinputname$.view" ReplaceParameters="true">Template.view</ProjectItem> <ProjectItem SubType="Code" TargetFileName="$fileinputname$.view.cs" ReplaceParameters="true">Template.view.cs</ProjectItem> <ProjectItem SubType="Code" TargetFileName="$fileinputname$.data.cs" ReplaceParameters="true">Template.data.cs</ProjectItem> <ProjectItem SubType="Code" TargetFileName="$fileinputname$.gen.cs" ReplaceParameters="true">Template.gen.cs</ProjectItem> <ProjectItem TargetFileName="$fileinputname$.js" ReplaceParameters="true" ItemType="Embedded Resource">Template.js</ProjectItem> </TemplateContent> <WizardExtension> <Assembly>VisualStudio.TemplateWizards, Version=1.1.0.0, Culture=neutral, PublicKeyToken=87390d63f27c23a4</Assembly> <FullClassName>VisualStudio.TemplateWizards.ViewItemTemplateWizard</FullClassName> </WizardExtension>
The problem is that the JavaScript file is nested under the .View file, and I cannot find a way around this. I ideally want this to be the only element template that has been added (and should not use two separate element templates).
Any help would be greatly appreciated. Everything works for me, I just need to polish this last piece.
source share