Sunday, March 15, 2009

Sharepoint Solution Mangement - How will Redeploying my solution affect my Features?

Someone mentioned to me the other day that they were about to make updates to their Live Sharepoint site, this meant editing their Sharepoint Solution package (.wsp file) and redeploying, but they were nervous as they weren't sure what would happen.
The reason for their nerves was that they had a List Feature (with a SFeatureReceiver class) that created a list from a .stp file (with content in it). Since initial deployment their list had been edited and had new items in it, they didn't want the reployment to affect the content of this list.

So their options are -

stsadm -o upgradesolution command

or the following commands one after eachother

stsadm -o retractsolution
stsadm -o execadmsvcjobs
stsadm -o deletesolution
stsadm -o addsolution
stsadm -o deploysolution
stsadm -o execadmsvcjobs


Although there isn't much difference between the two options there are some subtle differences. The first command (stsadm -o upgradesolution) should be used to update what is already there in the solution. i.e Features that are already installed (There is a difference between Features in the 12 hive and Features that are fully installed).
The second set of commands can be used if you are adding a new Feature to your wsp. The new Feature will appear in the manifest.xml (as below).

Old Manifest.xml



New Manifest.xml

If you use the UpgradeSolution command for a new Feature then it will never get installed to your Site. This means you'll never see it from the Site Features or the Site Collection Features pages (Although it may well appear in the 12 hive).


The next question would be "Ok so I have a new Feature, but what happens to the already Installed and Activated Features if I run the above commands? Do they get ReActivated?"

The answer to this would be NO your already installed and Activated Features don't get reActivated... But they do get reinstalled! This means if you have a SPFeatureReceiver class like below then the only part which will be "run" is the Installed part -

This shouldn't affect anything in your site as all the work is done on the activation of the feature... Installing it really just means that the Feature is available throough the UI to activate.



Hope this cleared up a few Sharepoint grey areas.

No comments:

Post a Comment