Thursday, November 06, 2008

How To Deploy Web Parts in MOSS 2007

Requirement: Deploy Web Part to SharePoint Site.

Procedure:
  1. Build your Web Part with Strong Name: Create a ClassLibrary Project.
  2. Drag and Drop the CustomWebPart.dll to GAC (C:\Windows\Assembly).
  3. Open the VirtualDirectories Folder (C:\Inetpub\wwwroot\wss\VirtualDirectories) and go to the Root Folder of your site. ( For Example your site is "http://localhost:801/sites/TestSite", then open the folder "801".)
  4. Open web.config file and add an SafeControl entry for your web part like, (Note: PublicKeyToken can be copied from GAC).
  5. Reset IIS
  6. Go to your site and Click on "Site Settings" => "Web parts".
  7. Click on "New" web part and Select your Web part and click on "Populate Gallary".
  8. Now go to your site and click on edit page. Click "Add a Web part". Select your web part under "Miscellaneous" section and click on "Add".
  9. You can see your web part now.
Deploy Web part by building Cab file.
  1. Build your Web Part with Strong Name: Create a ClassLibrary Project.
  2. Drag and Drop the CustomWebPart.dll to GAC (C:\Windows\Assembly).
  3. Add "CustomWepPartCab" cab project to the above solution(File => New => Project => Other Project Types => Setup and Deployment Project => Cab Project => "CustomWepPartCab")
  4. Add "Project Output.." by right click on cab project.
  5. Select "Primary output" and "Content Files".
6. Add a new file "manifest.xml" to the cab project as follows:
Note: Please make sure that file name(manifest.xml) is not changed

"











"

7. Add another file with name "CustomWebPart.dwp", the name given in the maifest.xml file as follows:
"

Custom Webpart
Custom Webpart
CustomWebpart, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b6ad7af95de74642 publickeytoken value from GAC
CustomWebpart.CustomWebpart

"

Deploying the Cab file:
  1. Go to command prompt(Start => Run => Cmd)
  2. Change the directory to the location where cab file(CustomWebPart.cab) is build.
  3. Execute the following command
  4. stsadm.exe -o addwppack -filename WebPartCab.CAB -url http://SiteUrltoInstallWebPart -globalinstall -force

No comments: