Tuesday, 11 October 2011

How to deploy custom webpart from one SharePoint 2010 Server to another SharePoint 2010 Server


Recently, I was working on a suite of web parts in test server. Everything was proceeding fantastically until I needed to deploy my farm solution (containing many web parts) from my test server to another SharePoint development serve. Visual Studio 2010 provides outstanding functionality for creating Web Parts for SharePoint, and can deploy them locally (provided that SharePoint is installed locally), but it cannot deploy them to a different remote server.
So, upon searching, I stumbled across many bits and pieces of information regarding how to deploy SharePoint farm solutions, but alas, I could not find a single article which contained all of the necessary steps to get a web part to appear in SharePoint. After several frustrating hours I was able to discover the procedure, and now, I am here to pass it along to you. So without further ado…
1. Copy the WSP file to your SharePoint server (WSP to be deployed) Eg: Paste it in c:\backup\
2. Open the SharePoint 2010 Management Shell
3. stsadm –o addsolution -filename {WSP file name}
Eg: stsadm -o addsolution -filename c:\backup\Newsss.wsp

                 
4. stsadm –o deploysolution –name {WSP file name} –url http://{the name of your SharePoint server} –immediate –allowGacDeployment –allowCasPolicies
Eg: stsadm -o deploysolution -name Newsss.wsp -url http://gvasp2010test:81/ -immediate -allowGacDeployment –allowCasPolicies

                
5. stsadm –o activatefeature – name {name of feature} –url http://{the name of your SharePoint server}
Eg: stsadm -o activatefeature -name Newsss_Feature1 -url http://gvasp2010test:81/


6. Go in to SharePoint and your web parts should appear.

One thing which was poorly documented and tricky to figure out was the activation of the feature. Please notice the name parameter of step 5 says name of feature, not name of solution. This is important as if you do not enter the correct name, the web part will not be activated and will be unavailable. The feature name (if unchanged in Visual Studio) usually follows the naming convention of:
{solution name}_Feature1

I hope this helps you on your way to developing compelling web parts for SharePoint 2010.
Happy SharePointing………