我在Visual Studio中爲一個類創建了自定義項目模板。我已經完成了所有必需的步驟,並且可以將模板作爲除「共享項目」類型之外的每個項目類型添加爲新項目。添加新項目時,它不顯示在選項列表中。我的目標是將此模板用於共享項目中的新類。Visual Studio中共享項目的項目模板
這裏是我的模板.xml文件...
<VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Item">
<TemplateData>
<DefaultName>Class_ODBC.cs</DefaultName>
<Name>Class_ODBC</Name>
<Description>Template for a class using ODBC and System.Data</Description>
<ProjectType>CSharp</ProjectType>
<SortOrder>10</SortOrder>
<Icon>__TemplateIcon.ico</Icon>
<TemplateGroupID>WinRT-Managed</TemplateGroupID>
</TemplateData>
<TemplateContent>
<References />
<ProjectItem SubType="" TargetFileName="$fileinputname$.cs" ReplaceParameters="true">Class_ODBC.cs</ProjectItem>
</TemplateContent>
</VSTemplate>
而對於模板本身的cs文件...
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Odbc;
using System.Text;
namespace %rootnamespace%
{
class %safeitemname%
{
#region Fields
#endregion
#region Constructors
#endregion
#region Methods
#endregion
#region Events/Handlers
#endregion
#region Properties
#endregion
}
#region Exceptions
#endregion
}
任何幫助是極大的讚賞。
可否請您分享您的解決方案如何做到這一點。 – PhuocLe