创建和使用 SharePoint 功能包

上次修改时间: 2010年3月31日

适用范围: SharePoint Server 2010

当您创建包含 XmlFormView 控件的自定义网页时,.aspx 页只属于 SharePoint 服务器的根网站集。要在非根网站集下创建网页,应将自定义网页部署为 SharePoint 功能。SharePoint 功能需要两个简单的 XML 文件,并使用 stsadm.exe 命令行工具进行部署,通过使用批处理文件可以自动使用该工具。

示例 Feature.xml 和 Module.xml 文件

下面是一个示例 Feature.xml 文件,它是为功能提供唯一 ID 和指向 Module.xml 文件所必须的文件。

<?xml version="1.0"?>
<Feature Id="8C4DD0CB-5A94-44da-9B7F-E9ED49C2B2DC" Title="Custom Web page"
Description="This simple example feature adds an aspx page with a hosted
XmlFormView control" Version="1.0.0.0" Scope="Web"
xmlns="https://schemas.microsoft.com/sharepoint/">
<ElementManifests>
    <ElementManifest Location="Module.xml"/>
</ElementManifests>
</Feature>

Module.xml 文件包含有关作为解决方案的一部分的页面的信息。

<?xml version="1.0"?>
<Elements xmlns="https://schemas.microsoft.com/sharepoint/">
    <module name="file" url="" path="">
        <file url="XmlFormViewPage.aspx" type="ghostable"> </file>
    </module>
</Elements>

将 file url 值更改为 .aspx 页的名称,然后运行下一部分所述的命令行。您可以创建一个批处理文件并按顺序运行这些命令行。

运行 Stsadm.exe 命令以部署和激活该功能

  1. 在服务器的 Features 文件夹下创建一个文件夹,该文件夹通常位于 C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\FEATURES。

  2. 将自定义 .aspx 页添加到此文件夹。

  3. 根据上一部分中提供的示例创建 Feature.xml 和 Module.xml 文件,并将这两个文件添加到同一位置。

将功能部署到 SharePoint

用于部署功能的命令行语法是:

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\bin\stsadm -o installfeature –filename FeatureFolderName\Feature.xml

激活 SharePoint 网站集上的功能

用于激活功能的命令行语法如下所示:

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\bin\stsadm -o activatefeature –filename FeatureFolderName\Feature.xml -url https://ServerName/Sitecollection

将 ServerName 和 SiteCollection 分别替换为 SharePoint 服务器的实际名称和要激活其功能的网站集的名称。

请参阅

概念

创作包含 XmlFormView 控件的自定义网页

其他资源

频道 9 截屏视频:创建和部署针对 Windows SharePoint Services V3 的功能(该链接可能指向英文页面)