Packaging a Visual Web Part

This section assumes that the previous section was completed successfully and the web part displays, as shown in Figure 29.23 (with the exception that most likely a different image displayed). To deploy the solution to a staging or production machine, follow these steps:

  1. With the SharePoint 2010 solution open in Visual Studio 2010, access the Solution Configuration drop-down menu on the Standard toolbar, as shown in Figure 29.25, visible just beneath the top menu bar, and change the configuration to Release. The next time the project is built, Visual Studio 2010 generates each project’s binaries (DLLs) without the debug symbols, making them optimized for deployment to production environments.

    Figure 29.25. Change the project to Release Configuration for Production-Ready Code.

    image

  2. Next, rebuild the solution by clicking the Build menu and choosing Rebuild Solution.
  3. Open the Solution Explorer and right mouse key on the project name, and choose Package, as shown in Figure 29.26. Packaging the solution creates a SharePoint solution file with the familiar .wsp extension. The solution file is a compressed cab file that contains the web part’s DLL, its visual components, and a manifest.

    Figure 29.26. Creating a package of the EventWebPart project.

    image

  4. After packaging the project, a solution file with the .wsp extension appears in the project’s bin/release directory. To locate this directory, open Windows Explorer from the Start menu, and navigate to DocumentsVisual Studio 2010Projects EventWebPartEventWebPartinRelease. Within the release directory, the .wsp file should appear, as shown in Figure 29.27.

    Figure 29.27. Locating the .wsp file.

    image

  5. On the Start menu, click All Programs, Microsoft SharePoint 2010 Products, and SharePoint 2010 Management Shell.
  6. At the Windows PowerShell command prompt, type the following command, where <SolutionPath> is replaced by the full path to the .wsp file, including the .wsp filename, as shown in the top part of Figure 29.28, and press Enter:

    Add-SPSolution -LiteralPath <SolutionPath>

    Figure 29.28. Using PowerShell to add the solution.

    image

  7. The PowerShell screen should then show the name of the solution, the SolutionID, and the Deployed state, which is false at this point.
  8. Next, navigate to the Central Administrator site; click System Settings. In the Farm Management section, click Manage Farm Solutions.
  9. On the Solution Management page, click the solution eventwebpart.asp.
  10. On the Solution Properties page, click Deploy Solution, as shown in Figure 29.29.

    Figure 29.29. Deploying the solution from the CENTRAL ADMINISTRATION site.

    image

  11. On the Deploy Solution page, in the Deploy When section, leave the Now option selected.
  12. In the Deploy To section, select a specific web application. In this example, http://abcsp1004 is selected. Click OK.

The web part should now be available to add to the test site (http://abcsp1004/sites/test), as it was during the debugging process.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset