WSPBuilder 產生Webpart 部署套件

來源:互聯網
上載者:User

這裡以我做的一個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>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.