Sunday, September 13, 2009

Deploying Sharepoint Webparts

Deploying a Web Part solution includes more tasks than simply copying assemblies and resource files, and updating the SafeControl list. For example, it is recommended , apply custom code access security permissions for the assembly to function properly.
Additionally, when preparing to deploy a Web Part across a server or server farm that includes multiple portals sites, you may choose to deploy to Web Part only to specific virtual servers.
1. Steps for Deploying SharePoint Web Part via manualy
I.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)
II.Copy DWP file to C:\Inetpub\wwwroot\wpcatalog
III.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
IV.Adjust web.config
- Register as SafeControl
- Select Code Access Security settings
2. Steps for Deploying SharePoint Webpart via CAB File
a. CAB file should contain
-Assembly DLL
-DWP file(s)
-Manifest.XML
-Resource files (if needed)
b. CAB won't contain
- Code Access Security settings
c. Server-side object model has methods for deploying such a CAB file
d. 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]

3.Creating a code-only webpart and deploying as a feature
Building a simple web part in Visual Studio is deceptively simple. However, deploying the web part (or anything else) to SharePoint is not nearly as easy. The proper way to deploy almost anything to WSS 3.0/MOSS 2007 is by creating one or more features and distributing the feature(s) with a solution package. Solution packages are nothing more than .cab files with a .wsp extension. Building a solution file manually involves a number of steps and can be tedious and error prone. Fortunately for developers, Carsten Keutmann (http://keutmann.blogspot.com/) has created a wonderful tool that allows developers to quickly and easily create solution packages without knowing the intricacies of makecab.exe. diamond definition files, manifest.xml files or SafeControl entries.

WSPBuilder is available as both a command-line executable and a Visual Studio add-in. More detail on this can be found at

http://www.sharepointsean.com/articles/Pages/CreatingaCode-Onlywebpartanddeployingasafeature.aspx"

No comments: