First we need to build .wsp file.

How to build WSP file.

open visualstudio 2010 –> File –> New –> Project

select sharepoint 2010 template on leftside panel, .Net Framework 3.5 and select visual web part, click on “OK”.

It will open sharepoint customization wizard, in that specify webapplication url where will u deploy this .wsp file. then click on “finish”.

Now design usercontrol. am taking one button and one label here.

Now press F5.

Here u might get deployment error after build.

Error Msg is: “Error occurred in deployment step ‘Recycle IIS Application Pool’: Cannot connect to the SharePoint site: http://websitename . Make sure that this is a valid URL and the SharePoint site is running on the local computer. If you moved this project to a new computer or if the URL of the SharePoint site has changed since you created the project, update the Site URL property of the project.”

ignore that error message. wsp is generated successfully u can find .wsp file in solution bin folder.

Now how to deploy and activate feature.

am copying this file and placing in another location that is “D:\DeploymentFiles”.

we can deploy .wsp using stsadm and powershell.

here am using powershell cmdlets.

1. add solution to sharepoint

Add-SPSolution “D:\Deploymentfiles\Sample4WSP.wsp”

2. Deploy solution to a webapplication

Install-SPSolution –Identity Sample4WSP.wsp –WebApplication http://192.168.0.11:2244 –GACDeployment

3. Activate feature( without activating the feature we cannot see this webpart in webpart gallery).

Enable-SPFeature –Identity Sample4WSP_Feature1 –url http://demoshare:8086

to confirm whether the feature is activated or not we have to execute another command that will show all activated features

“get-spfeature -site http://demoshare:8086 | sort displayname”