SharePoint Feature Upgrade: Update all Sharepoint modules


In my previous post, I have explain basics overview of feature upgrade. But in some specific scenarios, like update xslt, masterpage, css files which are already deployed to libraries, it is required to write a custom code which will iterate through file content and replace it with new one. This post is not a reference for those who can easily perform actions like adding new fields to content type, adding new columns but can be referenced for those who want to replace the existing one and one does not sure about the fact that whether the file is ghostable or not.

All those files which are ghostable in library, i.e. those are deployed in library and not modified using SPD or any other SP tool, can be easily modified by feature upgrade without writing the custom code. But for other files which are present in library but moved to content database, we have to write some code to update those files.

Requirements: CKSDev tool, SharePoint Feature Upgrade Kit

Development Steps:

    1. Open the project to update to visual studio tool.
    2. In project properties change Active Deployment Configuration to Upgrade Solution (CKSDev)

    3. Save the UpgradeHelper_cs
    4. Next step is to add file (as link) UpgradeHelper.cs to the project.In Solution Explorer right click on Project -> Add -> Existing Item ->  Navigate to <Solution Folder>/CommonClasses  -> Select file UpgradeHelper.cs -> Click Add
    5. Change Feature Manifest file to update the version of the feature:                        <?xml version=”1.0″ encoding=”utf-8″ ?><Feature xmlns=”; ImageUrl=”REC.Direct\rec-direct-feature.png” Version=”″><UpgradeActions><VersionRange BeginVersion=”″ EndVersion=”″><CustomUpgradeAction Name=”UpdateAllModules”></CustomUpgradeAction></VersionRange></UpgradeActions></Feature>
    6. Last step is to override FeatureUpgrading method in Feature Receiver class

public override void FeatureUpgrading(SPFeatureReceiverProperties properties, string upgradeActionName, System.Collections.Generic.IDictionaryparameters)
var definitions = properties.Definition.GetElementDefinitions(CultureInfo.CurrentCulture);
using (var site = (SPSite)properties.Feature.Parent)
if (upgradeActionName == "UpdateAllModules")
UpdateAllModules(definitions, site);
private static void UpdateAllModules(SPElementDefinitionCollection elementDefinitions, SPSite site)
foreach (SPElementDefinition elementDefinition in elementDefinitions)
if (elementDefinition.ElementType == "Module")
UpgradeHelper.UpdateFilesInModule(elementDefinition, site.RootWeb);

Deployment Steps:

Perform the following steps in order to deploy the upgraded features to the server:

1)      Add solution “COB.SharePoint.Utilities.FeatureUpgradeKit.wsp” to SharePoint by executing given PowerShell command.

Add-SPSolution –LiteralPath <folder path>/COB.SharePoint.Utilities.FeatureUpgradeKit.wsp

2)      Deploy COB.SharePoint.Utilities.FeatureUpgradeKit.wsp package globally by navigating to

“Central Administration> System Settings> Manage farm solutions” then click on the solution name and then click on Deploy Solution.

3)      Update existing deployed solution using PowerShell. In order to upgrade first

  1. Open the management PowerShell (Start> All Programs>Microsoft Sharepoint 2010 Products> SharePoint 2010 Management Shell)
  2. Run the following command:

Update-SPSolution –LiteralPath <folder path>/SPSolution <Solution name>

4)      Feature Upgrade: Once solution was updated on the SharePoint farm next is to upgrade the features which were modified during the development. Perform following steps to upgrade the feature:

  1. Navigate to feature upgrade page: Central Administration -> System Settings -> Manage Feature upgrades
  2. Appropriately select an option in Select Feature scope to query for Web-application/Site/Web (not required for farm solutions)
  3. Select Only Features requiring upgrade
  4. Click Search
  5. Select the appropriate features to upgrade and click Upgrade Feature


Happy Sharepointing 🙂

Published by Mohit Vashishtha

Having extensive experience in software industry as a Team Lead and SharePoint consultant. I have worked with various MS technologies like SharePoint, .Net, AngularJS and Angular 6. I love to learn and share new things which I learn during my experience.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: