Click here to Skip to main content
15,888,263 members
Articles / Web Development / CSS
Tip/Trick

SharePoint Features, Packages and Solutions

Rate me:
Please Sign up or sign in to vote.
5.00/5 (2 votes)
22 Dec 2015CPOL4 min read 7.5K   2  
This tip gives a brief on how to create and manage Sharepoint web applications using SharePoint Central Administration Website.

Introduction

In this tip, we are going to see features, packages and solutions in SharePoint.

Features

SharePoint 2013 provides us an option to use the components as plug and play services which means that we can activate/deactivate components in a particular site or in all the sub sites of a site as per the requirements.

The features in a SharePoint Site are available (activated by default) based on the site template we choose while creating the site. We can also create the features by using Visual Studio. Once we add any kind of solution using Visual Studio, a feature is created by default. We can set the Scope of the feature as follows:

  1. Farm: The feature is activated at the farm, meaning all the components available in the feature are available across the SharePoint Farms, i.e., for all the Web Applications in the Farm.
  2. Web Application: The feature is activated at the Web Application, in the sense that the components of the feature are available across all the site collection in that particular Web Application.
  3. Site: When we set the scope of the feature as Site, then once the feature is activated, all the components of the feature are available across all site and all the sub sites within a Site Collection.
  4. Web: When we set the scope of the feature to Web, the components are limited only to the current site.

Package

Packages in SharePoint are available as ".wsp" files meaning Windows Solution Package. Package contains all the features of a SharePoint project. Apart from the features, we can also add assemblies to the Package with the target deployment settings either as Web Application or GAC.

Once all the required features are available within the package, we can deploy the package to SharePoint using either Visual Studio or SharePoint Administration tool know as PowerShell.

Activity: Building and Deploying Solutions to SharePoint using Visual Studio

Scenario

Consider a scenario where we are supposed to create a feature which automatically applies a master page to Current and all its sub sites.

Assumptions

Let us assume that we already have a custom master page and CSS files suitable to the existing branding of the portal. Now, we need to deploy these files to the Master page gallery and CSS files to the CSS folder and apply the deployed master page to the parent and sub sites.

The following steps are used to achieve this:

  1. Right click on the solution explorer choose SPSTraining Project and click on Add New Item.
  2. Choose Module from the available template and click on Add.
  3. Once the Module is added, the following files are available in the solution, "elements.xml" and sample.txt.
  4. Right-click on the Module and Choose "Add Existing Item" and add the available Master Page and CSS files to the solution.
  5. Once the files are added to the module, the following lines of code mapping the files to the module are added to the elements.xml file:
    XML
    <module name="SPSMasterFiles">
            <file path="SPSMasterFiles\SPSMaster.Master" url="SPSMasterFiles/SPSMaster.Master" />
            <file path="SPSMasterFiles\SPSMaster.css" url="SPSMasterFiles/StyleSheet1.css" />
    </module>
    
  6. All the above created files are available in the feature; we can also use a separate feature only for the master page by adding a new feature and induce the module in it.
  7. Right click on the Feature and click Add Feature, this adds new feature to the solution.
  8. We can choose the required items that need to be available in the feature by selecting the items from the list box as shown below.
  9. Now as the files are ready in the feature and are added to package, after deployment, the files are copied to the Master pages Gallery folder.
  10. And to apply the deployed master page to the current site and sub sites, we need to write the following lines of code in the feature activation event (more information about Event Receivers is available in the upcoming articles).

Deployment of Solutions using PowerShell

The following steps are used to deploy the solution to SharePoint using PowerShell Commands.

  1. Right click on the Solution Explorer and click on Properties. From the Properties Window, click on Compile and Choose Release in Configuration dropdown.
  2. Now Build the solution and click on publish option, check publish to File System Radio button, browse the location to save the wsp file and click on publish.
  3. This creates the solution package (.wsp file) in the file system for our solution.
  4. Open the SharePoint PowerShell Window in administrator mode from the start menu.
  5. Enter the following command in the command window.
    Add-SPSolution -?
  6. The above command displays complete syntax and description on how to add the solutions to SharePoint.
  7. Now enter the following command in the command window to add the solution.
    Add-SPSolution –LiteralPath "D:\SPSTraining.wsp"
  8. Once after execution of the above code, the command Prompt displays the Name, Solution Id and deployed attribute values as shown below.
  9. Now once after adding the solution to the central admin, the solution is under solution gallery as shown below.
  10. We can manually go and install/deploy the solution from the central administration as shown below or by using PowerShell commands.
  11. The following command is used to deploy the solution to the SharePoint.
  12. Install-SPSolution –Identity "SPSTraining.wsp" –GACDeployment.

Points of Interest

This post is part of a series of articles on Sharepoint for beginners.

Below are the list of articles on "Sharepoint for beginners."

  • SharePoint - Web Application Management
  • SharePoint Lists and Libraries
  • SharePoint Features, Packages and Solutions

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer Collabera
Singapore Singapore
S V Sai Chandra is a Software Engineer from Hyderabad Deccan. He started Embedded Programing in his college days and now he is a Web Developer by Profession. He Loves coding and his passion has always been towards Microsoft Technologies. Apart from coding his other hobbies include reading books, painting and hang out with friends is his most favorite past time hobby.
He blogs at
http://technowallet.blogspot.com
Technical Skills:
C#,Ado.Net,Asp.Net,Sql Server,JavaScript,XML,Web services.

Comments and Discussions

 
-- There are no messages in this forum --