Tuesday, September 23, 2008

SharePoint: Deploying WebPart/Feature as SharePoint Solution Package (.wsp file) - Part 4

Link to Part 1 : Creating Skeleton.
Link to Part 2 : Creating Features/Webparts
Link to Part 3 : Creating .ddf and Manifest.xml
Link to Part 4 : Using STSADM and Centeral Admin to add and deploy solution (current post)

Upon successfull completion of build, you will se two additional folder, in bin\debug directory. Namely:
  • cab: contains cab file
  • wsp: contains wsp file
reason for creating cab file is:
  • to verify is all referenced file are included in the solution
  • to verify file heirarchy

Upon successful verification of solution, we move forward on how to deploy solution in SharePoint 2007.

Deploying the solution file to SharePoint is a two-step process: First, register the solution in the database. Registration is accomplished from the STSADM command-line utility. To add the test.wsp file, run the utility like this:

STSADM –o addsolution –filename test.wsp 
Second, once the solution has been added to the solution store you can deploy it from the command line, or you can deploy it using the Central Administration user interface. Find the Solutions Management page by going to Start-->Administrative Tools-->SharePoint 3.0 Central Administration-->Operations, and in the Global Configuration section clicking Solution management. From there, click one of the listed solutions to see its status and to take action on it—like deploying it.

Alternatively, you can deploy the solution from the command line with the STSADM command deploysolution. If you want to deploy the test.wsp solution to the local system, issue this command:

STSADM –o deploysolution –name test.wsp –allcontenturls –local –allowgacdeployment –allowcaspolicies 
The allowgacdeployment and –allocaspolicies options are necessary only if you have indicated deploying an assembly to the GAC, or you have provided a CAS policy as a part of the solution file, respectively.

Hope this helps !!! 

Cheers

10 comments:

Anonymous said...

This is the best article I ever ream for WSP creation.
Thanks.

Anonymous said...

Could you explain where you get the [code] from? Ex: in manifest.xml and the ddf file.

Sandeep said...

I wrote it.

Sandeep said...

Check out the XML Schema file at following location:

%programfiles%\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\XML\wss.xsd

This is a good starting point.

Meenu Dhiman said...

I get this error. Please suggest the solution.

Error 5 The command ""C:\Documents and Settings\mdhiman\My Documents\Visual Studio 2008\Projects\MDHandsonWSP\MDHandsonWSP\makecab.exe" /f "C:\Documents and Settings\mdhiman\My Documents\Visual Studio 2008\Projects\MDHandsonWSP\MDHandsonWSP\tt.ddf" /D CabinetNameTemplate=test1.wsp /D DiskDirectory1=wsp


"C:\Documents and Settings\mdhiman\My Documents\Visual Studio 2008\Projects\MDHandsonWSP\MDHandsonWSP\makecab.exe" /f "C:\Documents and Settings\mdhiman\My Documents\Visual Studio 2008\Projects\MDHandsonWSP\MDHandsonWSP\tt.ddf" /D CabinetNameTemplate=test1.cab /D DiskDirectory1=cab
" exited with code 1. MDHandsonWSP

Sandeep said...

check your ddf and makecab.exe paths

Meenu Dhiman said...

....
I checked my all the path. Its same as u have in ur example code. but i am doing this on my local system not on the server.

Please give some hint for this error.

Sandeep said...

cross check your paths mentioned in ddf file

Anonymous said...

I got this error:

Failed to instantiate file "MD.aspx" from module "mymodule": The specified list does not exist.

please suggest me :)

mepfuso said...

For my deployed web part, I had the problem that I got the error "Unable to add web part" when trying doing so in sharepoint site.

For me, the reason was that the Visual Studio Sharepoint Webpart Template created the following entry in the .webpart file:

<!--
The following Guid is used as a reference to the web part class,
and it will be automatically replaced with actual type name at deployment time.
-->
<type name="81141d10-3f58-47ac-875f-b03029cfe0b6" />

Now, as I deploy manually, it was not true what that xml comment says that the type name would automatically be replaced. So, I had to put the type name there by myself to fix things:

<type name="MyWebPartTestNameSpace.MyWebPart, MyWebPartTestAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxx" />