Answered by:
Item Template with multiple files not working correctly

Question
-
Hi,
I have the following item template I created:
<VSTemplate Type="Item" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Version="2.0.0"> <TemplateData> <DefaultName>SLServer.slsd</DefaultName> <Name>SL Server</Name> <Description>A server class generated from the SL Communications Library.</Description> <ProjectType>CSharp</ProjectType> <ProjectSubType>Client/Server</ProjectSubType> <SortOrder>10</SortOrder> <Icon>server.ico</Icon> <RequiredFrameworkVersion>3.5</RequiredFrameworkVersion> </TemplateData> <TemplateContent> <ProjectItem SubType="Code" ReplaceParameters="true" TargetFileName="$fileinputname$.slsd">SLServer.slsd</ProjectItem> <ProjectItem SubType="Code" ReplaceParameters="true" TargetFileName="$fileinputname$.slsd.designer.cs">SLServer.slsd.designer.cs</ProjectItem> <ProjectItem SubType="Code" ReplaceParameters="true" TargetFileName="$fileinputname$.slsd.cs">SLServer.slsd.cs</ProjectItem> </TemplateContent> </VSTemplate>
The problem is that it doesn't add the last two ProjectItem's under the first one, it just adds three seperate files to the project. I want the last two items to go under the first, like code-behind files do for ASPX pages.
Your help is appreciated.
Thanks,
--MikeWednesday, February 25, 2009 5:58 AM
Answers
-
Hi, Michal
I guess the reason is: VS Item Template doesn't support this structure:
--slsd
----slsd.designer.cs
----slsd.cs
The hierarchy of Solution Explorer doesn't recognize it, so they cannot be organized together.
I tried this normal structure, it's ok:
--cs
----designer.cs
----resx
Sincerely!
Please mark the replies as answers if they help and unmark them if they provide no help.- Marked as answer by Wesley Yao Wednesday, March 4, 2009 2:11 AM
Tuesday, March 3, 2009 10:27 AM
All replies
-
Sticky: How to ask questions to increase your chances of an answer
Return to the source, learn the way!Thursday, February 26, 2009 12:44 AM -
I'm not sure what additional information you want. From the template it is obvious that the laguange is C#. IDE is visual studio 2008. Title specifies that it is an item template.
Steps to reproduce...add the template to VS2008 and for some reason it adds three seperate files instead of one item with two subitems. From everything I've read, item templates should add a single item + subitems. I'm not sure why it is adding the items as seperate entities.
I got the designer.cs file to appear as a subitem because I removed it from the item template and added a custom tool to generate it instead. But the other .cs file still gets added as a seperate item.
I can't find any explanations or troubleshooting tips as to why subsequent items would be added as seperate items instead of subitems in a muti-item template. Any direction as to where I can even begin would be great. I just want the user code file (.slsd.cs) to appear as a subitem of the .slsd file.
ThanksThursday, February 26, 2009 7:16 AM -
Hi, Michal
I guess the reason is: VS Item Template doesn't support this structure:
--slsd
----slsd.designer.cs
----slsd.cs
The hierarchy of Solution Explorer doesn't recognize it, so they cannot be organized together.
I tried this normal structure, it's ok:
--cs
----designer.cs
----resx
Sincerely!
Please mark the replies as answers if they help and unmark them if they provide no help.- Marked as answer by Wesley Yao Wednesday, March 4, 2009 2:11 AM
Tuesday, March 3, 2009 10:27 AM -
Hi Michael,
Would you mind sharing some info on your custom tool that adds the the code behind files behind your main file? Do you have any links or anything. ThanksSunday, May 31, 2009 2:56 AM -
Linking to similar post.
- Dan - "Can't never could do anything"Friday, August 26, 2011 4:23 AM