How to Deploy SharePoint WebParts

There are several ways to skin the Webparts deployment cat, each with a few pluses and minuses. Thanks to Mark Harrison we have have a quick and pragmatic list of the options, complete with instructions.

Method 1 – manual

  • Copy assembly DLL to either
    – /bin directory for a given IIS virtual server (e.g., c:\inetpub\wwwroot\bin)
    – Global Assembly Cache (e.g., c:\windows\assembly)
  • Copy DWP file to C:\Inetpub\wwwroot\wpcatalog
  • Copy resources to
    – For GAC-registered parts, C:\Program Files\Common Files\Microsoft Shared\web server extensions\wpresources
    – For Web Parts in the /bin directory, C:\Inetpub\wwwroot\wpresources
  • Adjust web.config
    – Register as SafeControl
    – Select Code Access Security settings

Method 2: CAB File

  • CAB file should contain
    -Assembly DLL
    -DWP file(s)
    -Resource files (if needed)

  • CAB won’t contain
    – Code Access Security settings
  • Server-side object model has methods for deploying such a CAB file
  • Deploy with STSADM.EXE
    Located in C:\Program Files\Common Files\Microsoft Shared\web server extensions\60\BIN
    Add it to your path
    Stsadm -o addwppack -filename filename [-globalinstall] [-force]

Method 3: MSI File via WPPackager

  • All of the features of CAB file deployment, but with
    – Code Access Security support
    – Ability to uninstall via Control Panel
  • Get WPPackager.exe
  • Add additional files to project for use by WPPackager
  • Run WPPackager after project is built

Content Query Web Part – Field Types

Over the last few months I have had to configure various Content Query Web Parts (CQWP) to provide portal rollups that can be pre-packaged and re-configured in the SharePoint UI instead of having to use SharePoint Designer when using Data View Web Parts.

I could go into the basics of setting up a CQWP, but since others have done it for us I’ll just provide some link love here. Even though this post if fairly old it provides a TON of value for those getting started with the CQWP, but the main thing I find missing is how to identify the items needed in the CommonViewFields property. You can find the internal field name pretty easy by going to your list settings, and then look at the URL when you hover over the column you want to identify. The Field Query String parameter gives you the internal name you need.

Now that you have the internal name for the columns you need, now you need the column type.  I haven’t been able to find a decent resource for all of the column types, so I figured this is where I needed to list them all out:

Display Column Type

Internal Column Type

Single line of text


Multiple lines of text








Date and Time






Person or Group


Hyperlink or Picture





Of course these are all the default column types you can create, however there are some others, like the Publishing columns such as:

Display Column Type

Internal Column Type

Publishing Image


Publishing HTML


Another nice way to see what these values are would be to use PowerShell.  I will often drop into PowerShell and look at the fields in a specific list to view the internal name, along with other variables, the following lines will output a table of all fields associated with a list and the Display Name, Internal Name, Display Column Type, and the Internal Column Type:




$site = new-object Microsoft.SharePoint.SPSite(“http://moss150”)

$web = $site.OpenWeb()

$list = $web.Lists[“CQWP”]

$list.Fields | Format-Table Title, InternalName, TypeDisplayName, TypeAsString

Having these items should now set you up to have all the information you need to customize your Content Query Web Part. Just create a customized template in the ItemStyle.xsl (or create your own custom XSL file and link to it using the ItemXslLink property in your .webpart file) to render the information you need and you should be ready to start utilizing the infamous Content Query Web Part.

Displaycustom fields in a Content Query Web PartD


Add a Content Query Web Part to a page.
* In the Query section, set the Source to show items from the Knowledge Base Articles document library (list). Set the list type and content type accordingly.
* In the Presentation section, set the Item Style to Title and description.


Edit the properties in the Web Part file to display custom fields. To access the .webpart file for the Web Part, on the Web Part’s edit menu, click Export.
* Office SharePoint Server 2007 generates a .webpart file with the complete set of properties that are available for this Web Part. The .webpart file is an XML file that you can edit using a text editor.

In the .webpart file, locate the CommonViewFields property. Use this property to specify the additional fields you want to display in the Web Part. Add the internal names of the columns and the type.
Copy Code



You cannot use your columns’ display names in this property. You can find the internal column names by checking the properties of the column in the list or document library. Right-click the column, and then click Properties. The internal name of a column appears in the Address (URL) property after ‘Field=’. In the Knowledge Base Articles scenario, the columns are Knowledge Base Article and Product and their internal names are KB_x0020_Title and Product, respectively.

Map these internal column names to the columns’ Title and Description present in the XSLT transformations. To do this, edit the DataColumnRenames property.
Copy Code



The default XSLT transformations can render the following four fields: Title, Description, LinkUrl, and ImageUrl. In your DataColumnRenames property, verify that the names you specify match the names in the XSLT transformations; that is, Title, Description, LinkUrl, and ImageUrl.

Save the .webpart file locally.

In the Web page, delete the Content Query Web Part you added in step 1.

Import the .webpart file and add the Web Part to your page. To import the .webpart file, click Page, click Add Web Parts, and then click Import. Browse to the .webpart file, and then click Upload.

Drag the Web Part to the appropriate zone in the page. The Web Part should display the Knowledge Base Title and the product name.

Customize the Content Query Web Part by using Custom Properties


Requests additional fields, which is necessary because the Content Query Web Part does not return all fields for all items automatically. You must request fields to render in an XSLT transformation.

This property is additive, meaning that you can add more than one CommonViewField to a Content Query Web Part and extend its base properties, such as FieldDescription and FieldTitle.


Bypasses limits to query behavior imposed by the Content Query Web Part UI. Makes it possible to specify the query portion of a cross-list query in CAML.

When the QueryOverride property is set, the UI for filtering, sorting, and grouping appears dimmed in the tool pane. For example, by default the Content Query Web Part allows three filters, and you might want to add more and ensure that the customized fields and behavior persists in the UI.


Determines whether the cross-list query should recurse subsites. By default, Office SharePoint Server 2007 recurses subsites, meaning that the parent site and its child sites are displayed.

When the WebsOverride property is set, the Content Query Web Part does not recurse, and displays results from only the specified site.


Overrides the list behavior in Office SharePoint Server 2007, and supports several types of lists, such as Page Libraries, the General List base type, and specific list types. You can use this custom property to set any list type, even those not enumerated in the UI because the template is not defined at the root or is a base type.

List types are defined in the List element reference topic in the Windows SharePoint Services 3.0 SDK.


Gives the Content Query Web Part the ability to request a set of fields from the query that you specify, instead of making the automatic request in Office SharePoint Server 2007 for the base fields.

Gives the Content Query Web Part the ability to rename columns before the data is passed to the XSLT transformation for rendering.