Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers 2

up vote 3 down vote accepted

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.

share|improve this answer
add comment

when I try querying the site for my feature by using the SPSite.QueryFeatures("Web", $true) using PS, the collection does not return my feature. I've updated the Feater definition Version value to a high version then previous and then after recompile and package, I called the update-spsolution command and this ran without any issues.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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