这里以我做的一个SSO Webpart为例
随便创建一个目录,把WSPBuilder的相关文件拷入,在Feature下创建要部署到Feature下的目录名,如BruceLeeSSOWebpart,那么最后文件就被部署在12\TEMPLATE\FEATURES\BruceLeeSSOWebpart。
把feature.xml和elementManifest.xml和*.webpart拷贝到FEATURES\目录。
Dll拷贝到GAC下。
feature.xml文件格式解释
<?xml version="1.0" encoding="utf-8"?>
 <Feature Id="f80676eb-f08e-46db-bff5-db9848ff33e6" Title="BruceLeeSSO部件" Scope="Site" Version="1.0.0.0" Hidden="FALSE" DefaultResourceFile="core" xmlns="http://schemas.microsoft.com/sharepoint/">
   <ElementManifests>
     <ElementManifest Location="elementManifest.xml" />
     <ElementFile Location="具体名字.webpart" />
   </ElementManifests>
 </Feature>
ID,一个Feature的唯一ID
Title="BruceLeeSSO部件"是设定出现在Moss网站功能中的现实。
Scope是激活后的应用范围
ElementManifest 指定elementManifest.xml位置
ElementFile 指定“具体名字.webpart”位置
elementManifest.xml文件格式说明
<?xml version="1.0" encoding="utf-8"?>
 <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
   <Module Name="WebParts" List="113" Url="_catalogs/wp">
     <File Path="具体名字.webpart" Url="具体名字.webpart" Type="GhostableInLibrary" />
   </Module>
 </Elements>
Path指定*.webpart路径
*.webpart格式说明
普通情况下<importErrorMessage>和property name="Title" type="string">不能有中文字,因为文件缺省格式是ANSI格式,另村委UTF-8后可以有中文
<?xml version="1.0" encoding="utf-8"?>
 <webParts>
   <webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
     <metaData>
       <type name="BruceLeeSSOWebpart.BruceLeeSSOWebpart, BruceLeeSSOWebpart, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f34244ef5a35e827" />
       <importErrorMessage>无法导入此 Web 部件。</importErrorMessage>
     </metaData>
     <data>
       <properties>
         <property name="Title" type="string">BruceLeeSSO部件</property>
         <property name="Description" type="string">SSO。</property>
         <property name="ChromeType">None</property>
         <property name="CatalogIconImageUrl" type="string">/_layouts/images/wp_Filter.gif</property>
         <property name="TitleIconImageUrl" type="string">/_layouts/images/wp_Filter.gif</property>
       </properties>
     </data>
   </webPart>
 </webParts>
 出错
 “检测到不兼容的 Web 部件标记。请使用 *.dwp Web 部件 XML,而不要使用 *.webpart Web 部件 XML。”
 因为把Webpart的继承改为了Microsoft.SharePoint.WebPartPages.WebPart,并把AssemblyInfo.cs文件的[assembly: CLSCompliant(true)]注释了。
 所以如果部署文件用*.webpart那么webpart的继承类一定要用System.Web.UI.WebControls.WebParts.WebPart
 否则会报上面的错误。
 所以如果部署文件用*.dwp那么webpart的继承类一定要用Microsoft.SharePoint.WebPartPages.WebPart
 Webpart继承于Microsoft.SharePoint.WebPartPages.WebPart,那么ToolPart比较容易定义,直接用属性就可以实现,如果继承System.Web.UI.WebControls.WebParts.WebPart要自己实现ToolPane
 否则会报上面的错误。
 dwp文件和elementManifest.xml、feature.xml
 <?xml version="1.0" encoding="utf-8"?>
 <WebPart xmlns="http://schemas.microsoft.com/WebPart/v2">
    <Assembly>BruceLeeSSOWebpart,Version=1.0.0.0,Culture=neutral,PublicKeyToken=f34244ef5a35e827</Assembly>
    <TypeName>BruceLeeSSOWebpart.BruceLeeSSOWebpart</TypeName>
    <Title>BruceLee SSO Web 部件</Title>
    <Description>集成OfficeSSO。</Description>
 </WebPart>
 <?xml version="1.0" encoding="utf-8"?>
 <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
   <Module Name="WebParts" List="113" Url="_catalogs/wp">
     <File Path="BruceLeeSSOWebpart.dwp" Url="BruceLeeSSOWebpart.dwp" Type="GhostableInLibrary" />
   </Module>
 </Elements>
 <?xml version="1.0" encoding="utf-8"?>
 <Feature Id="6c629a18-5758-4b52-8198-f82ef15f0225" Title="BruceLeeSSO部件" Scope="Site" Version="1.0.0.0" Hidden="FALSE" DefaultResourceFile="core" xmlns="http://schemas.microsoft.com/sharepoint/">
   <ElementManifests>
     <ElementManifest Location="elementManifest.xml" />
     <ElementFile Location="BruceLeeSSOWebpart.dwp" />
   </ElementManifests>
 </Feature>