Академический Документы
Профессиональный Документы
Культура Документы
Microsoft Corporation
May 2003
Applies to:
Summary: Learn how to package and deploy Web Parts by using the administration tools provided with
Note The information in this article also applies to Microsoft Office SharePoint Portal Server 2003, which
is built on the Windows SharePoint Services platform.
Contents
Introduction
Switches
Conclusion
Introduction
Web Parts are more than just the assemblies into which they are compiled. A Web Part may have class
resources such as images, Microsoft JScript® files, and Help files. These files may also be localized and
deployed in locations that are different from the location of the Web Part. Additionally, the Web Part must
be added to the SafeControl list for the specific virtual server before users can take advantage of its
functionality.
Prerequisites
• Familiarity with Microsoft Windows® SharePoint™ Services and/or Microsoft Office SharePoint
A Web Part package is a cabinet (.cab) file that contains the following items:
1. Manifest.xml (mandatory)
The Manifest file, a configuration file that describes the structure and contents of the .cab file, is the only
required component for the .cab file. The Stsadm.exe tool uses this file to deploy the remaining content of
The following table describes the nodes and subnodes in the Manifest.xml file.
The following example shows a manifest file for a package that deploys two assemblies and their
resources:
<WebPartManifest
xmlns="http://schemas.microsoft.com/WebPart/v2/Manifest">
<Assemblies>
<Assembly FileName="WebPartLibrary1.dll">
<ClassResources>
<ClassResource FileName="image1.gif"/>
<ClassResource FileName="image2.gif"/>
</ClassResources>
<SafeControls>
</SafeControls>
</Assembly>
<Assembly FileName="WebPartLibrary2.dll">
<ClassResources>
<ClassResource FileName="MyCustomHelp.htm"/>
<ClassResource FileName="LargeIcon.gif"/>
</ClassResources>
<SafeControls>
</SafeControls>
</Assembly>
</Assemblies>
<DwpFiles>
<DwpFile FileName="WebPart1.dwp"/>
<DwpFile FileName="WebPart2.dwp"/>
</DwpFiles>
</WebPartManifest>
Developers can use either of the following methods to create a .cab file:
• Use MakeCAB.exe, a command-line tool included with Microsoft Windows 2000 and later.
To use Visual Studio.NET Professional to create a CAB project, follow these steps:
• On the File menu, point to New, and then click Blank Solution.
• In Solution Explorer, right-click the new solution, point to Add, and then click Existing
Project.
• Browse to the location of Web Part project that you want to add, click the project, and
• In Solution Explorer, right-click the new solution, point to Add, and then click New
Project.
5. Under Project Types, click Setup and Deployment Projects, and then under Templates,
click Cab Project.
• Type a name for the CAB project, and then click OK.
• In Solution Explorer, right-click the CAB project, point to Add, and then click Project
Output.
• In the Project box, click the Web Part project that you added to the solution in step 3.
• Select all the appropriate file categories that appear in the list, and then click OK.
Make sure that you select Primary output and Content Files. These categories add the
Manifest.xml file, the .dwp files, and the Web Part assembly to the .cab file. Verify that the
Manifest.xml file and the .dwp files are marked as content for build action in their respective
properties sheets.
Using MakeCAB.exe
MakeCAB.exe is a tool included with Windows 2000 or later. To use MakeCAB.exe to create a .cab file,
1. Create a directive file for makecab.exe, and save the file with a .ddf extension. The following
sample directive file (named sample.ddf) creates a .cab file for a simple Web Part library project:
3. ;
5. .Set CabinetNameTemplate=SampleCab.cab
7. directory
9. .Set UniqueFiles="OFF"
12. manifest.xml
13. WebPart1.dwp
14. WebPartLibrary1.dll
16. Copy all the files that you want to include in the .cab file into the directory where you created the
.ddf file. In this example, these files are the Manifest.xml file, the WebPart1.dwp file, and the
WebPartLibrary1.dll file.
17. Open a command prompt, change to the directory that contains the .ddf file and the files that you
want to include in the .cab file, and then run the following command:
18. Makecab.exe /F sample.ddf
MakeCAB.exe creates a directory named SAMPLECAB.CAB, and in this directory MakeCAB.exe creates a
.cab file named SampleCab.cab that contains the three files listed in the Sample.ddf directive file.
For more information about MakeCAB.exe, download the Microsoft Cabinet Software Development Kit.
Visual Studio does not support creating .cab files with internal directories. However, localized Web Parts
may require a .cab file with internal directories. Because of this you must use a tool like MakeCAB.exe or
The following example describes how to create a .cab file for an English language Web Part project named
SampleWebPartLibrary that also provides German localized resources. The .cab file in this example is
• SampleWebPartLibrary.dll
• Help.htm
• Image1.gif
• WebPart1.dwp
• de-DE/Help.htm
• de-DE/Image1.gif
• de-DE/WebPart1.dwp
To create the .cab file for this example Web Part project, follow these steps:
1. Create the appropriate Manifest.xml file. The following example shows the Manifest.xml file for
the Sample.cab file:
3. <WebPartManifest
4. xmlns="http://schemas.microsoft.com/WebPart/v2/Manifest">
5. <Assemblies>
6. <Assembly FileName="SampleWebPartLibrary.dll">
7. <ClassResources>
8. <ClassResource FileName="image1.gif"/>
9. <ClassResource FileName="help.htm"/>
12. </ClassResources>
13. <SafeControls>
15. TypeName="*"/>
16. </SafeControls>
17. </Assembly>
18. </Assemblies>
19. <DwpFiles>
22. </DwpFiles>
23. </WebPartManifest>
24. Create the appropriate Makecab.exe directive file. The following example shows the directive file
for the Sample.cab file:
26. ;
30. directory
32. files
37. WebPart1.dwp
38. SampleWebPartLibrary.dll
39. Image1.gif
40. help.htm
42. de-DE\WebPart1.dwp
43. de-DE\image1.gif
44. de-DE\help.htm
46. Copy all the files that you want to include in the .cab file into the directory where you created the
.ddf file, and copy all of the localized resources into the appropriate subdirectories. The following
example shows the directory structure for the Sample.cab file:
48. Sample.ddf
49. Manifest.xml
50. SampleWebPartLibrary.dll
51. WebPart1.dwp
52. Image1.gif
53. Help.htm
54. \de-DE
55. WebPart1.dwp
56. Image1.gif
57. Help.htm
58. Open a command prompt, change to the directory that contains the .ddf file and the files that you
want to include in the .cab file, and then run the following command to create a subdirectory in the
Sample.cab file and prepare the Sample.cab file for deployment:
command-line tool that you can use to manage a Windows SharePoint Services computer. Three
• AddWPPack
• DeleteWPPack
• EnumWPPacks
For more information about a specific Stsadm.exe command-line option, type the following line at a
command prompt:
To use the Stsadm.exe command to deploy a Web Part package on a server computer running Windows
SharePoint Services, open a command prompt, and then type the following command:
stsadm.exe -o addwppack
-filename Web_Part_Pack_name
[-url URL]
[-globalinstall]
[-force]
If you want to install a Web Part package on a virtual server when the Web Part package is already
installed on another virtual server on the same computer, use the following command:
stsadm.exe -o addwppack
-name Web_Part_Pack_name
[-url URL]
[-globalinstall]
[-force]
Switches
The following table describes Stsadm.exe command-line switches that support adding Web Part packages.
Switch Description
Specifies the URL of the virtual server on which you
-url want to install the Web Part package.
Note If you do not use this switch, then the
package is installed on all Windows SharePoint
Services-enabled virtual servers on the computer.
To delete a Web Part package from specified virtual servers on a computer running Windows SharePoint
Services, open a command prompt, and then type the following command:
stsadm.exe -o deletewppack
-name Web_Part_Pack_name
[-url URL]
Switches
The following table describes Stsadm.exe command-line switches that support deleting Web Part
packages.
Switch Description
To list all the Web Part packages installed on a computer running Windows SharePoint Services, open a
stsadm.exe -o enumwppacks
[-name Web_Part_Pack_name]
[-url URL]
[-farm]
Switches
The following table describes Stsadm.exe command-line switches that support enumerating Web Part
packages.
Switch Description
To decide whether to install a Web Part package in the GAC or in the Bin directory, ask the following
questions:
• Do you want to make this package available to all virtual servers on your computer?
If you answer "yes" to both of these questions, install the Web Part package to the GAC. Assemblies in the
GAC are fully trusted and are available to all virtual servers.
The following table lists the differences between installing to the GAC and installing to the Bin directory.
URL: http://virtual_server/wpresources
http://virtual_server/_wpresources
Accessible by all Virtual Yes (The assemblies and types No (The Web Part package is only
Servers must be enabled in the accessible from the virtual server on
SafeControls list for each virtual which the assembly is installed.)
server)
Conclusion
You can use Stsadm.exe to deploy Web Part packages to the GAC or to the Bin directory for specified
virtual servers. This allows you to deploy Web Part packages across an entire organization or only to a