0

So I have read all Chris OBrien Feature upgrading blogs and I have a big question.

Lets suppose that I want to create a site from scratch and I want to activate a feature that has a feature activated event and also a feature upgrading event.

Sharepoint will automatically execute both I suppose, or it will execute the feature activated only and then I will need to upgrade using the feature upgrade toolkit?

4

As Chris explains in Feature upgrade (part 1) - fundamentals

Feature upgrade does NOT happen automatically (including when the Feature is deactivated/reactivated)! The only way to upgrade a Feature is to call SPFeature.Upgrade()

So, on first deployment you'll activate the Feature and the Feature_Activated event will run.

Now you make some changes and you upgrade the solution using the Update-SPSolution cmdlet. The files in the package get deployed but the Feature version doesn't change, the Feature_Upgrade event handler doesn't run, and none of the upgrade instructions in the Feature manifest execute. To get these things to happen you need to write code or use PowerShell to call the Upgrade method of the SPFeature object. I generally create a custom application page that users can use to do this.

Check out Deep dive into feature versioning and upgrade support in SharePoint 2010 for more details.

  • Can you update the link you posted in this answer? It's 404'ing. Thanks for the very helpful answer! – iOnline247 Mar 10 '15 at 21:42
  • 1
    I've updated the link – Rob Windsor Mar 10 '15 at 21:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.