About ProjectSubType of item template
-
Wednesday, June 13, 2012 11:02 AM
Hi all,
I create a file MyTemplate.vstemplate with the following
content:
<VSTemplate Version="2.0.0" Type="Item"
xmlns="http://schemas.microsoft.com/developer/vstemplate/
2005">
<TemplateData>
<Name>Class1</Name>
<Description>An empty class file</Description>
<Icon>Class.ico</Icon>
<ProjectType>CSharp</ProjectType>
<ProjectSubType>Web</ProjectSubType>
</TemplateData>
<TemplateContent>
<ProjectItem>Class1.cs</ProjectItem>
</TemplateContent>
</VSTemplate>I put this XML file into a test project folder and then
make a .zip file including the XML file and file
Class1.cs . I copy the .zip file into user item template
folder.
What I do above is for making a item template only
available for CSharp Web project. But when I add a new
item to a CSharp Web project, the template is not
displayed in the Add New Item dialog box.
Then I run DevEnv /Setup under command prompt of VS2008
and re-launch VS2008, I found the template is available
for not only CSharp Web project, but also other type of
CSharp project.
My environment: Win7 x64 + VS2008
Who can help me?
All Replies
-
Thursday, June 14, 2012 6:12 AMModerator
Hi sincos2007,
Try to set ProjectType as Web and set ProjectSubType as CSharp.
There is a refference about the ProjectSubType which you can refer to:http://msdn.microsoft.com/en-us/library/ms171386.aspx
If you have any more concerns about this issue, please feel free to let us know.
Best regards,
Ego
-
Thursday, June 14, 2012 6:47 AM
Hi Ego,
I have tried metadata of the item template as following:
<VSTemplate Version="2.0.0" Type="Item" Version="2.0.0"> <TemplateData> <DefaultName>Class.cs</DefaultName> <Name>Class1</Name> <Description>An empty class file</Description> <Icon>Class.ico</Icon> <ProjectType>Web</ProjectType> <ProjectSubType>CSharp</ProjectSubType> </TemplateData> <TemplateContent> <ProjectItem>Class1.cs</ProjectItem> </TemplateContent> </VSTemplate>
But I can not see the template in the Add New Item dialog box of the CSharp Web project.
And then I tried that metadata sample page you give me, I can not see the template in the Add New Item dialog box of the CSharp SmartDevice targets the .NET Compact Framework version 2.0.
Thanks.
- Edited by sincos2007 Thursday, June 14, 2012 6:48 AM
-
Monday, June 18, 2012 8:19 AMModerator
Hi sincos2007,
I did some test. And I found a way to realize your demand.
1.Set ProjectType as CSharp.
2.Add your .zip file to C:\Users\Your Folder\Documents\Visual Studio 2008\Templates\ItemTemplates\Visual C#\Web
Then you will get what you want.
Best regards,
Ego
- Edited by Ego JiangMicrosoft Contingent Staff, Moderator Monday, June 18, 2012 8:26 AM
- Proposed As Answer by Ego JiangMicrosoft Contingent Staff, Moderator Monday, June 18, 2012 8:27 AM
- Marked As Answer by Ego JiangMicrosoft Contingent Staff, Moderator Friday, June 22, 2012 6:02 AM
- Unmarked As Answer by sincos2007 Saturday, June 23, 2012 12:10 PM
- Unproposed As Answer by sincos2007 Saturday, June 23, 2012 12:10 PM
-
Saturday, June 23, 2012 12:24 PM
Hi Ego,
Sorry for my late reply.
You answer does not answer my question.
I need that my item template only is available for my CSharp Web project, or CSharp Office project. When I right click CSharp Web project, or CSharp Office project node in Solution Explorer and select Add New Item, I can see my item template. But If I right click CSharp Windows project and select Add New Item, I should not see my item template.
Thanks.
-
Monday, June 25, 2012 6:16 AMModerator
Hi sincos2007,
I'm sorry for my answer did not match your issue.
We can see a CSharp Web project and a CSharp Windows project are all edited by CSharp language. So it is hard to distinguish them from language.
I suggest you can add your own item template to the tab of CSharp/Web.
I have done many tests. I think it is a good way to group these templates. Though it is not what you want.
At once I get a better way to solve your issue, I will post it to you.
Best regards,
Ego [MSFT]
MSDN Community Support | Feedback to us
-
Monday, June 25, 2012 8:12 AMThank you, Ego.

