Sharepoint Webpart Deployment

Initially when I first created a webpart for Sharepoint/WSS, I was kind of confused with the number of development and deployment options and kept on wondering for a while for the way to go. You can and should develop the webpart using Visual Studio but you have option to derive from Sharepoint webpart class or from .NET Webpart Class. You can deploy the webpart as a feature or you can deploy it using CAB file. Then you have .DWP and .Webpart files.  


Sometime I even saw the message that not able to deploy the webpart since it doesn’t derive from Sharepoint Webpart class.  I wondered, why is it that I am forced to derive from Sharepoint Webpart class when I don’t want to use any of the capabilities like inter-webpart communication etc etc.


I thought it would be helpful to jolt down some of my findings and post it here.

I already posted the comparison between deriving from Sharepoint Webpart class and .NET Webpart class. You can see it here


Now you have atleast 2 means to deploy the webpart…

1.      Deployment using CAB files

2.      Feature based deployment of a webpart


Deployment using CAB file, further vary a little when you are deriving from sharepoint webpart class or .net webpart class.


CAB based Deployment when deriving from Sharepoint Webpart Class

When you derive from Sharepoint Class, you should deploy create a DWP file like


<?xml version="1.0" encoding="utf-8"?>

<WebPart xmlns="" >

          <Title>Name of Webpart</Title>

          <Description>Webpart Description</Description>

          <Assembly>SampleAssemblyName, Version=, Culture=neutral, PublicKeyToken=<public key token></Assembly>


          <!-- Specify default values for any additional base class or custom properties here. -->



Save this file as <WebPartName>.dwp


One CAB project can be used to deploy one or more webparts. To guide the CAB project, you need manifest (With Name Manifest.xml) file. You create

Then, create a Manifest file, which guides the setup project about all dwp files, safe control entries and embedded resources etc etc..


Your manifest.xml may be something like..


<?xml version="1.0"?>

<WebPartManifest xmlns="">


    <Assembly FileName="WebpartAssemblyName.dll">


        <ClassResource FileName="RelativeFile1.gif"/>

        <ClassResource FileName="RelativePathtoFile2.jpg"/>



        <SafeControl Namespace="YourNamespace" TypeName="*"  />





    <DwpFile FileName="SampleDWP1.dwp"/>

    <DwpFile FileName="SampleDWP2.dwp"/>




Now you create a CAB project in Visual Studio and add Project Output of Webpart project to the CAB project. With that Manifest.xml will automatically be added. Next add DWP file and other resources as contents to CAB project.


CAB based Deployment when deriving from .NET Webpart Class

Here the process essentially remains the same, only the file content changes a little.


You create .Webpart file instead of .DWP and manifest changes a little.


Create a new file and name it as <WebpartName>.webpart. The content of file is as follows.


<?xml version="1.0" encoding="utf-8" ?>


          <webPart xmlns="">


                                                          <type name="FullnamespaceandWebpartClassName, AssemblyName, Version=, Culture=neutral, PublicKeyToken=<token>" />

                                                          <importErrorMessage>Cannot import this Web Part.</importErrorMessage>




                                                                                  <property name="Title" type="string">Webpart title</property>

                                                                                  <property name="Description" type="string">Webpart Description</property>






Create a new file manifest.xml with content as follows..


<?xml version="1.0"?>

<!-- You need only one manifest per CAB project for Web Part Deployment.-->

<!-- This manifest file can have multiple assembly nodes.-->

<WebPartManifest xmlns="">


                                  <Assembly FileName="WebpartAssemblyName.dll">

                                  <!-- Use the <ClassResource> tag to specify resources like image files or JScript files that your Web Parts use. -->

                                                          <!-- Note that you must use relative paths when specifying resource files. -->

                                                          <ClassResources />


                                                                                  <SafeControl Namespace="NameSpaceto be added as safecontrol in Sharepoint sites web.config." TypeName="*" />






                                  <DwpFile FileName="WebpartFileName.webpart"/>




The creation of CAB project is essentially the same.


For both of these cases, you can deploy the webpart using following STSADM Commands.


stsadm  -o deletewppack -name  <WebpartCabName>.CAB

stsadm  -o addwppack -filename <WebpartCabName.CAB > -globalinstall -url "http://<ServerName: PortNumber> " –force


Feature based Webpart Deployment

Here is a link to excellent post that steps to deploy webpart as a feature. Also you should see How Solution deployment has changed development with Sharepoint Technologies.

Skip to main content