Sunday, May 30, 2010

Using WSP Builder for creating and deploying a Solution

The WSP Builder is an excellent tool for creating Solution package automatically, and I am using this for a long time, so thought to write about it.

This tool is created by Carsten Keutmann and can be installed on bot VS2005 and VS2008. First you have to download from the codeplex then install.

Earlier, we had to create a "CAB Project" from the "Setup and Deployment" section on the Visual Studio. Then add the other project as resources to this CAB Project, Build the project and rename the output file extension to WSP, looks like lots of steps and efforts!!! WSP Builder is a single step creation.

Only thing need to to is Right Click on the Project of the Solution Explorer, WSPBuilder -> Build WSP

This step will generate the log that shows the components added in the WSP file created.



Important: Please verify very closely the output logs generated and check all the required DLLs are added in the WSP or not.

Once you have successfully built the WSP, now its time to deply it using STSADM commands. For this you have to navigate to the \12\BIN\ directory.

1st Command: AddSolution

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\BIN>STSADM.EXE -o addsolution -filename "E:\Project Server\Server Data\GenerateFormReceiver\EventReceiverBinder\EventReceiverBinder.wsp"
 

2nd Command: DeploySolution

STSADM.EXE -o deploysolution -name EventReceiverBinder.wsp -immediate -allowGacDeployment -url http://somu/pwa



Gotcha: The above command will give you an error "This solution contains no resources scoped for a Web application and cannot be deployed to a particular Web application."
At this point you might think there is problem in the Features.xml file, where you are trying to re-defining the scope property.

But the trick is, the DeploySolution cammand should not use a deployment scope, means the "url" switch at time moment. Therefore the solution will be globally deployed.

STSADM.EXE -o deploysolution -name EventReceiverBinder.wsp -immediate -allowGacDeployment

voilla!!! you successed.

3rd Command: ActivateFeature

STSADM.EXE -o activatefeature -name EventReceiverBinder -url http://Somu/PWA -force

And you are done.

Uninstalltion script:

Deactivate The feature:

STSADM.EXE -o deactivatefeature -name EventReceiverBinder -url http://Somu/PWA -force

Retracting the Solution:

STSADM.EXE -o retractsolution -name EventReceiverBinder.wsp -immediate

(Wait for couple of seconds...)

Deleting the Solution:

STSADM.EXE -o deletesolution -name EventReceiverBinder.wsp

 if you have not wait for the period, might encounter the following error.

The solution "EventReceiverBinder.wsp" has been deployed in the farm. Please retract the deployment before removing the solution.You can also use the -override parameter to forcibly remove the solution, but you will not be able to retract the solution deployment.

No comments: