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…
1: <?xml version="1.0" encoding="utf-8" ?>
2: <Solution xmlns="http://schemas.microsoft.com/sharepoint/"
3: SolutionId="AF597DAB-65D7-4c1a-A012-D04184CA647E">
4: <Assemblies>
5: <Assembly DeploymentTarget="WebApplication"
6: Location="SPDataPart.dll">
7: <SafeControls>
8: <SafeControl
9: Assembly="SPDataPart, Version=1.0.0.0, Culture=neutral, PublicKeyToken=8c9fc716f38d08b2"
10: Namespace="SPDataPart" TypeName="*"/>
11: </SafeControls>
12: </Assembly>
13: </Assemblies>
14: </Solution>
- 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.
Hey Robert –
Check out the VSeWss, authoring and deploying a webpart now is as simple as hitting F5. Neat!