首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式碼之家 >> 編程語言 >  >> .NET 網頁程式設計 >> 關於.NET

WSS 3.0 SDK 深度解析:Feature.xml 結構與屬性完整指南

     編輯:關於.NET

Feature.xml 核心角色

每個 SharePoint Feature 的定義核心,Feature.xml 中的 <Feature> 元素宣告 Feature 身分、範圍、相依組件、元素清單與屬性包。位於 12\TEMPLATE\FEATURES\FeatureName\ 目錄下。

Feature 元素完整屬性表

屬性類型預設說明
ActivateOnDefaultBooleanTRUE安裝/建立 Web App 時自動啟用。Site/Web 範圍不適用。
AlwaysForceInstallBooleanFALSE強制重新安裝,即使已安裝。所有範圍生效。
AutoActivateInCentralAdminBooleanFALSE管理中心/站台集/Web App 預設啟用。Farm 範圍不適用。
CreatorText-作者資訊。
DefaultResourceFileText-指定共用資源檔(預設找 Resources\Resources.<Culture>.resx)。
DescriptionString-功能描述。
HiddenBooleanFALSE隱藏不在 UI 顯示。
IdText (GUID)必填Feature 唯一識別碼。
ImageUrlText-UI 顯示圖片相對路徑。
ImageUrlAltTextText-圖片替代文字。
ReceiverAssemblyText-事件接收器組件強名稱(配合 ReceiverClass)。
ReceiverClassText-事件處理類別完整名稱。
RequireResourcesBoolean-驗證特定語言資源檔存在才顯示於 UI(僅影響 UI 啟用)。
ScopeText必填範圍:Farm、WebApplication、Site、Web。
SolutionIdText-所屬 Solution ID。
TitleText-顯示標題(≤255 字元)。
VersionText-System.Version 格式(最多四段數字)。

子元素結構

ActivationDependencies:啟用相依性

宣告本 Feature 啟用所需的其他 Feature:

<ActivationDependencies>
  <ActivationDependency FeatureId="11111111-1111-1111-1111-111111111111" />
</ActivationDependencies>
  • 相依 Feature 若為 Hidden 且未啟用 → 自動啟用;最後一個相依者停用時一併停用。
  • 相依 Feature 若為 可見 → **不自動啟用**,需手動啟用。
  • Hidden Feature **不能**有自己的 ActivationDependencies。
  • **不支援跨範圍**相依(如 Web 範圍相依 Site 範圍)。

ElementManifests:元素清單與檔案

  • <ElementManifest Location="..." />:包含 Feature 元素定義的 XML 檔(如 ListTemplate、ContentType、Field 定義)。
  • <ElementFile Location="..." />:支援性檔案(如 .aspx、.js、.css、圖片),不解析為元素定義,僅部署至 12 Hive。

Properties:Feature 屬性包

鍵值對集合,啟用時可由事件接收器讀取:

<Properties>
  <Property Key="Color" Value="Blue" />
  <Property Key="Shape" Value="Triangle" />
</Properties>

完整範例

<Feature
  Id="11111111-1111-1111-1111-11111111111"
  Title="Location Services"
  Description="This Feature contains lists and parts that let you link location data to your customer lists."
  Scope="Web">
  <ActivationDependencies>
    <ActivationDependency FeatureId="11111111-1111-1111-1111-111111111111" />
  </ActivationDependencies>
  <ElementManifests>
    <ElementManifest Location="Location\LocationPart.xml" />
    <ElementManifest Location="CustomerLocation\CustomerLocationList.xml" />
    <ElementFile Location="test.aspx" />
  </ElementManifests>
  <Properties>
    <Property Key="Color" Value="Blue" />
    <Property Key="Shape" Value="Triangle" />
  </Properties>
</Feature>

重要限制與注意事項

  • Feature 資料夾與檔名**僅支援低位 ASCII,不可含空格**。
  • RequireResources 僅影響 UI 顯示,**不阻擋 stsadm 命令列或物件模型啟用**。
  • Site Definition 內的 Feature 不受 RequireResources 強制約束,需自行確保資源完整。
  • 語言代碼格式遵循 IETF 標籤:ll-Ssss-CC(如 zh-TW、en-US)。

掌握 Feature.xml 結構,是開發可部署、可國際化、可相依管理的 SharePoint Feature 基石。

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式碼之家 All Rights Reserved