環境要求:vs2008
目标:自定義模闆,當vs2008建立項目時可以使用模闆建立
1,在vs中建立項目,并修改至所要求的模闆程度
現在假設我的解決方案中有兩個項目:

2,file-->export template...(建立單個項目模闆)
為testproject1項目建立模闆,填寫模闆description,finish之後彈出myexportedtemplate檔案夾;
為testproject2項目建立模闆,填寫模闆description,finish之後彈出myexportedtemplate檔案夾;
3,将testproject1.zip和testproject2.zip 解壓複制到任意操作檔案夾中(此處假設為d:/template/)
4, 在d:/template檔案夾下建立template.vstemplate檔案
5,用notepad編輯template.vstemplate
copy代碼并儲存:
<vstemplate version="2.0.0" type="projectgroup"
xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
<templatedata>
<name>mytemplate</name>
<description>mytempate descripiton</description>
<projecttype>csharp</projecttype>
<createnewfolder>true</createnewfolder>
<defaultname>name</defaultname>
<providedefaultname>true</providedefaultname>
</templatedata>
<templatecontent>
<projectcollection>
<projecttemplatelink projectname="testproject1">testproject1\mytemplate.vstemplate</projecttemplatelink>
<projecttemplatelink projectname="testproject2">testproject2\mytemplate.vstemplate</projecttemplatelink>
</projectcollection>
</templatecontent>
</vstemplate>
6,将testproject1檔案夾,testproject2檔案夾,template.vstemplate檔案壓縮為template.zip檔案
7, copy template.zip到c:\users\xxxx\documents\visual studio 2008\templates\projecttemplates檔案夾下
8,至此,完成目标。可在vs2008 file-->new project -->c# 中看到:
啦啦啦~~