Upgrading SharePoint webpart properties during solution upgrade

Pretty much any custom SharePoint solution will have web parts deployed as part of it. If it’s in production for a long time – chances are you will be upgrading your artifacts including webparts at least once during the lifetime of the solution. One of the things to keep in mind – your webpart definition files are not upgraded during the solution upgrade.

Usually when it comes to upgrading webparts – you update the code behind and new DLL replaces the old DLL whether in GAC or in the BIN folder of your SharePoint site. In case you would like to set initial web part properties when instances of web parts get created or update any other attributes in web part definition file you will have to execute some custom upgrade actions.

All of the web part definitions live in the site collection library called web part gallery under site settings (this is MOSS you’re looking at below)

You will notice that although the feature you use to provision your webparts is upgraded (the new feature artifacts can be found in C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\[Feature name]) and reactivated – the definition in the gallery will still remain the same. Even if you manually deactivate and activate the feature.

You actually have to delete current web part definition file from the gallery and then deactivate/activate the feature – the new definition will be dropped into the gallery.

Now, if you’re using automated deployment – you can script the upgrade procedure of deleting the old definition and reactivating the feature provisioning new webpart.

Before you go and start creating custom code – check out Gary Lapointe’s STSADM and PowerShell extensions and CMDlets to save yourself some time.

Good Luck!

This entry was posted in sharepoint, sharepoint 2010 and tagged , . Bookmark the permalink.

Comments are closed.