Monday, July 6, 2015

SharePoint 2013: Feature Versioning

Feature Versioning Overview 
Feature versioning allows Features and their associated instances to be easily tracked. Features has a version number that can be specified in the respective feature.xml file. When a Feature is activated, a Feature instance is created and associated with that version of the Feature. When a new version of a feature is deployed, the associated Feature instance also needs an upgrade as the instance version number is lower than the new version number specified in the current feature.xml file.

Update a new column/Modify an existing column
1. Update the Feature version, if a Feature does not have a Version attribute, the version is 0.0.0.0. To update the feature set it to 1.0.0.0

 Feature Versioning SharePoint 2013

2. Open the feature manifest and add the Upgrade Actions

 Feature Versioning Upgrade Actions

In the UpgradeActions place a VersionRange to tell the versions you are upgrading from and to. Give it the properties BeginVersion=”1.0.0.0″ and EndVersion=”2.0.0.0″. Between the VersionRange you can specify what will happen when we are upgrading from version 1 to 2.
3. Upgrade the solution in the farm


Update-SPSolution
-Identity FeatureVersioning.wsp
-LiteralPath C:\devprojects\ bin\Debug\ FeatureVersioning.wsp
–GACDeployment

4. After solution update, you need to call a feature.Upgrade(false) method to upgrade the  feature. 
The above method will update all the sites with feature version 1 to 2. That means you can have multiple version of the same feature installed, and selectively upgrade only the features you want. Multiple versions can live side-by-side. 
  • Microsoft SharePoint Foundation provides new members that make it possible for you to upgrade custom Features through versioning and declarative upgrade actions. As a result, you can perform the following kinds of modular upgrades to Features in SharePoint Foundation:
    • Define upgrade definitions for new Feature versions.
    • Provision a list instance as part of a Feature upgrade.
    • Create separate upgrade action sets, based on the Feature version, that remove different sets of files.
    • Apply settings to site collections where a particular Feature is activated.
  • See Also
http://www.sharepointnutsandbolts.com/2010/06/feature-upgrade-part-1-fundamentals.html  
http://www.deepcode.co.uk/2012/09/using-sharepoint-2010-feature-upgrades_28.html  
http://blog.furuknap.net/sharepoint-2010-feature-versions-and-upgrade-support 

No comments:

Post a Comment