Tuesday, June 16, 2009

Solution Feature Upgrading and Versioning

Managing features between releases of a SharePoint 2007 solution is tricky business.  Here are some considerations I have gleamed from recent upgrade issues:

·         Do not remove features from one version of a solution to another.  In theory you can remove a feature if it is deactivated on all sites and systematically uninstalled.  Practically I find this problematic, many features are so wound into the many systems it just is not practical.  Microsoft states that feature removal from a solution is not supported (see table below).

·         When adding new features to a site (web scope), use feature stapling to add them to the site templates.

·         For existing features that will be upgraded, update the Version tag on with your feature.xml.  This is not used in SharePoint 2007, but it will be in a future version.

·         Never add additional functionality to a SPFeatureReceiver on subsequent versions.  An existing deployment has already activated the feature receiver.  New sites will execute the new functionality and exiting sites will not.  Any additional setup that business logic is relying upon will not exist for existing sites.

·         Provide a path for activating the new features on existing deployed sites.  If your new solution contains 10 new features that are site collection (site scoped) or site (web scoped), these features will not be active on any existing sites of content database.  After you have installed your new solution into the farm it is necessary to activate these missing features.  This can be done in a couple of ways:

o    If you have written an external installer, you can have it systematically upgrade the previous sites and site collections throughout the farm (assuming proper permissions). 

o   You can add a single Farm level upgrade feature that auto activates and activates the missing features (assuming you can get the correct permissions).

o   You can add a site or site collection level feature that will go out and activate the missing features for that site collection or site.  This allows site owners to upgrade their sites piecemeal.  On caveat of this approach is that your entire business logic for your new solution must be able to function when these new features are missing.

Here are some recommendations from Microsoft. The following table was taken from Microsoft’s Feature Upgrading document:

Feature

Supported

Adding new files and removing old files in a new version of the solution.

Yes

Adding new Features in a new version of the solution.

Yes

Removing old Features in a new version of the solution

No

Changing the ID and/or scope of old Features in a new version of the solution.

No

Updating or changing the receiver assembly of old Features in a new version of the solution.

Yes

Adding or changing Feature elements or element XML files in a new version of the solution.

Yes

Removing Feature elements or element XML files in a new version of the solution.

No

Adding or changing Feature properties in a new version of the solution.

Yes

Removing Feature properties in a new version of the solution.

No