SharePoint 2010 : upgrading features (with versioning) is easier in the sandbox

In SharePoint 2010 it is well known that features can be versioned and upgraded accordingly.

This is well described in the following MSDN documentation:

Surprisingly, upgrading features requires calling the SPFeature.Upgrade() method of any feature that need to be upgraded.

Chris O’Brien provides  a set of tutorials that illustrate how to upgrade features in SharePoint and I recommend his posts

Chris also provide a nice tools (as well as a Powershell commandlet) to visually upgrade features.

It is less known that calling SPFeature.Upgrade() is not necessary (and not supported) in the Sandbox : when we upload a new solution package with a different name, but with the same solution Id, the features will automatically be upgraded.

To illustrate this, let’s create a Visual Studio 2010  Sandbox project called DemoUpgradeSandBox; add a web part to have a feature and set the feature version property to 1.0.0.0.

image

Deploy the solution with Visual Studio 2010 and make sure the solution package is deployed and activated  to the solution gallery.

Now, let’s change our feature version number to 2.0.0.0

 

 

image

Open the feature Manifest :

image

Add the following Upgrade Action:

image

Add a feature Receiver, to handle the upgrade by code :

image

 

Uncomment the FeatureUpgrading() method :

image

Build the project, rebuild the package, rename the package on the file system :

image

In Visual Studio 2010 set a breakpoint in the FeatureUpgrading method(), and attach the project to the sandbox host process (SPUCWorkerProcess.exe) :

image

Upload the new package into the solution gallery; since the same solution Id is used, SharePoint will ask you to upgrade :

image

Click on upgrade and you will hit the breakpoint in Visual Studio :

image

About these ads

3 responses to “SharePoint 2010 : upgrading features (with versioning) is easier in the sandbox

  1. Displaying custom list with multiple date fields in Calendar view in 2010

    I am using SharePoint 2010. I have a list for tracking project progress. I have multiple date fields in that list and most of them are calculated fields. I need to show these dates in Calendar view, as calendar view requires start date and end date ,it seems an item from list can only be shown as calendar view based on only two date fields. I am wondering it is possible to show those multiple dates related to an item in a calendar? Any suggestion would be highly appreciated? OTB or Visual Studio. Thank you!!!

  2. Pingback: Feature Upgrading in SharePoint 2010: Part 2 – Upgrade Fields & Content Types using Declarative XML – Silverlight and .Net | Sjoukje Zaal·

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s