This is one of those topics, which I frequently look up, and so what better place to put the information than this blog? Scot Hillier has explicit instructions in his book (Microsoft SharePoint – Building Office 2007 Solutions in C#) on page 404 to deploy a webpart using a solution package. The following instructions are an excerpt from his information.
Create a Strong Name Assembly
- Create a strong name for your web part (if you have not already done so), using sn-k c:keypair.snk.
- Add the key pair file to the project containing your web part.
- In the webpart project properties, sign the assembly using the key pair.
Create a Manifest File
- Add a new XML file to the webpart project, name this file manifest.xml.
- Add the following code to the XML file…
- Change the details in to match your webpart DLL name, strong name, and public key token.
- Note: If creating XML solution file is not your thing, Scot talks about a Visual Studio template on CodePlex to make solution file creation easier – link.
Create the Solution Package
- Add a new “CAB Project” to the solution, alongside the webpart project.
- Add “Project Output/Primary Output” from the webpart project to the CAB project – this adds the webpart DLL to the CAB.
- Add “Project Output/Content Files” from the webpart project to the CAB project – this adds the manifest file to the CAB.
- Build the entire solution.
- Find the CAB file in the bin/[Debug|Release] folder for the CAB project and rename the CAB extension to WSP.
- You now have a Web Solution Package.
Deploying Solution to SharePoint
- Run the following command on the SharePoint box to install the solution:
stsadm.exe -o addsolution -filename PathToMyWSPFile.wsp
- Open SharePoint Central Administration Console.
- Click the operations tab and then Solutions Management link.
- Click the solution package listed, which we added in step 1 of this section
- From the package options page, click deploy.
- Navigate to the top level site containing the web part.
- Go to the web part gallery under site settings.
- Click the New button.
- Check the webpart(s) from the list to add to the site.
- You are now ready to add the webpart to web part zones within the site.