Section 8.3. Deploying Web Parts


8.3. Deploying Web Parts

Importing a web part to a page installs the part in the web part page gallerythe web parts in that gallery are only available on that one page. That's usually what you want during development, since the web part isn't ready for general use. Once you

animal 8-3. Error loading the web part

animal 8-4. Error identifying the web part

move on to general testing and final deployment, you'll want to install the web part in one of the other galleries. Figure 8-5 shows the available web part galleries and explains the scope of each. The most common way to deploy web parts is to install them in the virtual server gallery. That makes the web part library available to all sites on the virtual server.

animal 8-5. Installing web parts in different galleries controls their scope

8.3.1. Deploying to the Virtual Server Gallery

To install a web part in the virtual server gallery, package the assembly, manifest, and description files as a CAB file and use the SharePoint Administration utility ( stsadm.exe ) to install the package. To make it easier to use stsadm.exe , add the following lines to the vsvars32.bat file you copied to the \WebParts folder earlier:

 @set STSBinDir=C:\Program Files\Common Files\Microsoft Shared\web server extensions\      60\bin      @set PATH=%STSBinDir%;%PATH%; 

Follow these steps to create and install the package from Visual Studio:

  1. Open the web part project in Visual Studio.

  2. Choose File Add Project New Project Setup and Deployment Projects Cab Project. Name the setup project WpSetup and choose OK.

  3. Add Project Output. Visual Studio displays Figure 8-6.
  4. Choose Build Rebuild Solution. Visual Studio rebuilds the web part assembly and packages the assembly and content files in the CAB file.

  5. Run stsadm.exe to install the CAB file on the server. For example, the following command line installs the web part library in the virtual server gallery:

     stsadm -o addwppack -filename WpSetup.cab 

8.3.2. Adding to the Site Gallery

Once the web part library is deployed to the virtual server, you can add those parts to the Team Web Site gallery from within SharePoint. The site gallery allows you to categorize web parts so they can be filtered from the task pane, as shown in Figure 8-7.

To add a web part to the Team Web Site gallery:

  1. Choose Site Settings Go to Site Administration Manage Web Part Gallery. SharePoint displays the Web Part Gallery page which lists all of the web parts installed in the site gallery.

  2. Select the web parts to add to the site gallery and choose Populate Gallery. SharePoint adds the web parts to the site gallery.

animal 8-6. Adding output and content to the CAB file

animal 8-7. Filtering web parts in the site gallery

To add a category for the web part:

  1. Choose the Edit Document Properties button on the Web Part Gallery page. SharePoint displays Figure 8-9.

  2. Select Specify your own value and enter the name of the custom category.

  3. Choose Save and Close to make the change and return to the gallery.

animal 8-8. Adding web parts to the site gallery

animal 8-9. Creating a category for a web part

8.3.3. Deploying as Windows Installer Files

Using CAB files is a simple way to deploy web parts. However if you want to include custom permission sets and allow uninstall from the Control Panel, you need to use the Web Part Packager utility ( wppackager.exe ) to create a Windows installer file ( .msi ) for deployment.

To use wppackager.exe to create an . msi file for a web part library:

  1. Download the utility from http://www.microsoft.com/downloads.

  2. Install the utility in the WebParts folder.

  3. Copy the assembly from \InetPub\ wwwroot \bin to the project folder. The location of the assembly must match the Assembly Filename attribute in the project's manifest.xml file.

  4. Copy the included packaging file ( wppackager.xml ) to the web part library project folder and edit it to reflect the web part project.

  5. Run wppackager.exe from the project folder to create the Windows installer (. msi ). For example:

     ..\wppackager wppackager.xml 

  6. Sign the . msi file with a public key. For example:

     signcode wpsetup.msi 

Once you've create the .msi file, you can install the web part library by running that file on the server. The installer walks you through the installation process providing a more friendly user -interface than the stsadm.exe utility.

The packaging file tells wppackager.exe what to include in the Windows installer file. For example, the following packaging file includes the web part library created earlier:

 <?xml version="1.0" ?>      <Wppackager xmlns="http://schemas.microsoft.com/WebPart/v1/Wppackager">        <Manifest FileName="Manifest.xml" />         <CodeAccessSecurity AssemblyName="WebPartLibrary1" Version="1.0.0.0"           PublicKeyBlob="a451359320dc76e6" >            <PermissionSet class="NamedPermissionSet" version="1" >              <IPermission                class="System.Web.AspNetHostingPermission, System, Version=1.0.5000.0,                Culture=neutral, PublicKeyToken=b77a5c561934e089"                version="1"                Level="Minimal"            />            <IPermission                class="System.Security.Permissions.SecurityPermission, mscorlib,                Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"                version="1"                Flags="Execution"            />            <IPermission class="Microsoft.SharePoint.Security.WebPartPermission,                Microsoft.SharePoint.Security, Version=11.0.0.0, Culture=neutral,                PublicKeyToken=71e9bce111e9429c"                version="1"                Connections="True"             />             <IPermission class="Microsoft.SharePoint.Security.SharePointPermission,                Microsoft.SharePoint.Security, Version=11.0.0.0, Culture=neutral,                PublicKeyToken=71e9bce111e9429c"                version="1"                ObjectModel="True"             />             </PermissionSet>         </CodeAccessSecurity>        <MSI Name="WPSetup1" Version="1.0.0.0" Manufacturer="SP2003 Sample" />       </Wppackager> 

Table 8-4 describes the elements in packaging files.

Table 8-4. Packaging file elements

Element

Description

Wppackager

Root element required for all packaging files.

Manifest

Identifies the location and name of the web part library's manifest.

CodeAccessSecurity

The permission set to be applied to the web part library.

PermissionSet

The minimal permissions needed to run a web part plus the SharePoint permission.

MSI

Determines the name of the MSI Installer and the Web Part package that is created.


More information about packaging files and custom permission sets can be found at:

  • http://msdn.microsoft.com/library/default.asp?url=/library/enus/odc_sp2003_ta/html/sharepoint_deployingwebparts_msi.asp

  • http://msdn.microsoft.com/library/default.asp?url=/library/enus/cpguide/html/cpconcodeaccesspermissions.asp

  • http://msdn.microsoft.com/library/default.asp?url=/library/enus/dnspts/html/sharePoint_WSSCodeAccessSecurity.asp

8.3.4. Deploying to the Online Gallery

The online gallery lists web parts deployed through a web service. By default, it is set to the Microsoft Office site through this setting in Web.config :

 <OnlineLibrary Url="http://r.office.microsoft.com/r/hlidAwsGallery" /> 

You can change the setting to point to a web service provided within your organization. There is no information on implementing the online gallery web service at this time, but I will post anything I find at http://usingsharepoint.com/Samples/OnlineGallery.aspx.



Essential SharePoint
Essential SharePoint 2007: A Practical Guide for Users, Administrators and Developers
ISBN: 0596514077
EAN: 2147483647
Year: 2005
Pages: 153
Authors: Jeff Webb

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net