We need to do the following to deploy the web part.
- First we need to sign the assembly.
- In Visual Studio right click project and select Properties.
- In properties, select Signing Tab.
- Select Sign the assembly check box.
- And specify the file or create a new file.
- Build the assembly.
- Now the manual way of deploying the assembly would be to put it either in GAC or bin directory of the web application and put a safe control entry within the web.config of the web application.
- However the preferred way of deploying is through a solution file, which would make our web part available in the solution management ( global configuration section) of Central administration page, from where we can deploy to multiple web applications.
- For this we need to create a manifest file.
- Right click the project.
- Add New Item – Select an xml file – name it manifest.xml
- Put the following code on the file
<?xml version=“1.0“ encoding=“utf-8“ ?>
Assembly=“DeploymentWebPart, Version=126.96.36.199, Culture=neutral,
Soution ID – Create and assign a new guid.
DeploymentTarget attribute, which has two possible values: GlobalAssemblyCache or WebApplication.
GlobalAssemblyCache indicates that the assembly should be deployed in the global assembly cache; WebApplication tells Windows SharePoint Services to drop the assembly in the private application folder of the IIS Web application
SafeControl element describes the configuration that must be done in the web.config file.
- Now we will create the solution package, which is essentially a cabinet file that would contain our assembly and manifest file.
- For this right click the project and select a CAB project from SetUp and Deployment projects folder.
- Name it as DeploymentWebPartSolution
- Right click the CAB Project and select – Add – Project Output.
- In Project Output Group dialog box select the DeploymentWebPart and from the configuration drop down select Active.
- In the project list box, select Primary Output to include the assembly.
- Now again right click the cab project and select – Add – Project Output, this time select Content Files to include the manifest.xml.
- Build the Project.
- This will create DeploymentWebPartSolution.CAB file.
- Rename it to DeploymentWebPartSolution.wsp
- To add the solution package to solution store
- Stsadm.exe -o addsolution -filename DeploymentWebPartSolution.wsp.
- We now go to Solution Management link inside the Global Configuration section within Operations Tab of Central Administration Site.
There we will see our DeploymentWebPartSolution.wsp. Now click on it and select the web application where it should be deployed.
However if are creating our web part using web part project template within Visual studio 2008, .wsp solution package automatically gets created for us when we select deploy command on right clicking the project. We can than make use of the .wsp file directly, no need to create a setup project in that case.
That’s it ….