Deploying a Custom Solution with Features

Let’s consider the following scenario: A custom solution needs to be deployed to CompanyABC SharePoint Portal. The solution has two features: a content type and custom web part, as shown in Figure 7.7.

Figure 7.7. The structure of custom ABC-Solution. It contains two features: a web part HelloWorld and a custom ContentType.

image

Here is the series of steps you need to do to install the ABC feature to a SharePoint environment.

The first step of this procedure is to install the solution from the file system to central solution farm store. Use this command (use the path where you have a .wsp file):

Add-SPSolution "C:My-SolutionsABC-Solution.wsp"

When the command installs the solution, it will be visible in the Central Administration, Solution Management. You need to deploy the solution via the central administration user interface or with the following PowerShell code:

image

The preceding command deploys solutions to all web applications (-AllWebApplications parameter) and also enables custom code to be deployed to Global Assembly Cache (GAC) via the –GACDeployment parameter. If the solution already exists, it will be overwritten (-Force).

To activate features on individual site collection, use the following code. The ABC solution has two features, and each needs to be enabled individually:

image

In the custom ABC-Solution, the HelloWorld web part is scoped as a site collection (Site) feature, and the ContentType is scoped as a site-level (web) feature. To activate it on every site in your site collection, run the following command:

image

To remove these features and solution, you must call commands in reverse order: First deactivate the feature, uninstall the solution, and then remove it. To perform these operations, type the following:

image

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

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