3

I'm looking into Feature versioning and upgrading in SharePoint 2010 and I don't know exactly if the Update-SPSolution cmdlet triggers a SPFeature.Upgrade().

Are <UpgradeActions> elements relevant only in the context of SPFeature.Upgrade()?

What does Update-SPSolution do when I update a solution which contains new feature versions?

1 Answer 1

9

As far as I know, the only way to upgrade a feature is by calling the Upgrade() method. Any other operation, including deactivation/reactivation, solution upgrade/update etc should in no way force a feature upgrade. I have upgraded some feature after a solution update in the past and they were NOT automatically upgraded by the Update-SpSolution cmdlet (I had to use my edited version of the Feature Upgrade page that Chris developed ^_^). This post on Chris blog also seems to confirm my experience - but anyone, fell free to add further references to Microsoft offical documentation as needed.

To elaborate on your second question - feature upgrade and solution update - they are different concepts.

To keep the same nomenclature used by the page you referenced Solution update is a special case of solution upgrade. You -upgrade- the solution any time you deploy a new version, but only some deploy may qualify for solution update (and even then you may chose to do a full retract/add cycle). As you can see from the linked page when you want to "install a new version of a solution" (the operation MSDN call upgrade - at last most of the times -_-') you have two options:

  • Retract solution / Add solution (solution Replacement): the most common option, you retract (/remove) the solution and then procede to add the new version. This procedure often requires additional action to be taken to avoid common problems (features deactivated on the solution retract etc).
  • Solution Update: you update the solution without retracting it. In this case, features remain untouched (no deactivation will be performed) but your assembly and other solution files will be updated.

As you see, most time solution update is the easier path to follow, but it isn't always possible due to the limitations that a new version must follow to qualify for solution update. To be clearer, you may want to use solution update to semplify a deploy process when:

  • you have only fixed some bugs in you codebehind, so only your solution dll have changed (please - DO NOT think about "I will just drop them in gac" ^_^).
  • you have only changed the layout of a custom control (moved a button, changed a label)
  • any other case that fits the requirement for update.

Feature upgrade on the other hand is something you may want to use to perform additional action when a new version of a feature is installed in the farm (remember, -you- must trigger the upgrade). Please refer to the documentation for further details - by using the feature upgrade framework you may (only some examples here):

  • Add a new field to a deployed site content type and have the change propagated to the derived list content types.
  • Rename a file in a module
  • Add a receiver handler that will execute your custom code when the feature is upgraded

Those were only some samples of what you can do. Basically with feature upgrade you may define an upgrade path - a set of operation that must be performed to allineate an already active feature to the current version. Just remember that deactivating the feature and then reactivating it will NOT execute any of the upgrade logic.

7
  • I know about that article, I've read it already but there are still some issues I don't understand. What confuses me is the fact that update/upgrade is used interchangeably in the docs. The help for Update-SPSolution states this Update-SPSolution cmdlet upgrades a deployed SharePoint solution.... There is this article with this in it: ...perform an update type of upgrade with the Update-SPSolution.... I mean...common... What is it? Update? Upgrade? What does Update-SPSolution do exactly?
    – JohnDoDo
    Oct 25, 2011 at 16:03
  • Sorry, I missed the last line of your question, so I didn't provide any detail about the difference. Edited my answer, fell free to ask if something doesn't seem clear enough.
    – SPArcheon
    Oct 26, 2011 at 8:32
  • Feature upgrade is not performed by updating your solution. UpgradeActions are only used for feature upgrade. The naming confusion on update/upgrade probably dates back to STSADM in SP2007 where the command was upgrade. Since SP2010 uses PowerShell they had to abide by the verb naming convention and hence used the verb Update. Oct 26, 2011 at 9:02
  • @AndersRask - don't know if it was your intention, but your comment made me notice the evident copy/paste refuse I leaved when editing the answer. Should have read "qualify for solution update" and not feature. Now it -should- be correct.
    – SPArcheon
    Oct 26, 2011 at 9:22
  • 2
    @JohnDoDo to simplify solution update can only be used when you update existing artifacts of your solution (like update a GIF, change code in a webpart, replace a Page Layout with another. As soon as you start adding new stuff or remove existing artifacts you cannot use solution upgrade (aka Update-SPSolution). This is where you either do what the MSDN article call Replacement, or even better use feature upgrade with either declaratively or programmatic approach. Check my article on feature upgrade in DIWUG magazine second issue information-worker.org/freemagazine.aspx Oct 26, 2011 at 13:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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