Using Microsoft Commerce Server 2009 Web Part Extensibility Kit for SharePoint 2007 Effectively

If you have worked with a Commerce Server 2009 SharePoint site (Default Site aka Template Pack) you have probably noticed that the quickest and most efficient way of re-skinning this site is to create new XSLT  templates for XSLT Web Parts and manipulating the style sheets (CSS) using SharePoint Designer.  Using these tools will give you the ability to leverage the Content Management capability of Microsoft Office SharePoint Server 2007 to manage changes in your SharePoint site’s look and feel.

That said, in some cases relying on these extensibility tools might not be enough so deeper customization may be required.  Using the Commerce Server Web Part Extensibility Kit as a base for a SharePoint based e-commerce solution might be of great value, especially for development teams new to this realm.

In this post we will introduce an effective way to reuse the Web Part Extensibility Kit as a base for sophisticated SharePoint commerce solutions. All projects in the Web Part Extensibility Kit need to be signed in order to be usable in an environment with strong name verification enabled. In addition, to achieve better customization the name space of the items in the extensibility kit need to be changed. You can achieve this easily with a series of search and replaces.

1. Unpack to a folder of your choice.

2. Open Visual Studio 2008.

3. Click on file\open\project or solution and browse to unpacked extensibility kit and open SharePointCommerce.sln.

4. Create a strong name key file and set up the projects to sign their assemblies using this key file.

a. Open the first project of the solution. Right Click on the project node and select properties.
b. On project properties go to signing tab.
c. Check the “Sign this assembly ” check box.
d. On “choose a strong name key file” drop down select “new”.
e. On Create Strong Name Key pop up provide a name for your key file like ExtKit and uncheck “Protect my key file with password” check box. This will create a key file for you.
f.  Go to the project property/ Application tab.
g. Click on Assembly Information and set assembly version to
h. Save the project properties.
i.  For every other project.

i.  Go to the project property/ signing tab.
ii. Check the “Sign this assembly ” check box.
iii. On “Choose a strong name key file” dropdown select brows and provide the path of the key file you have generated on step “e”.
iv. Go to the project property/ Application tab.
v.  Click on Assembly Information and set assembly version to
vi. Save the changes.

5. Fix  ProfileSharePoint project reference to Microsoft.SharePoint.ApplicationPages.

a. Open up ProfileSharePoint project in Solution Explorer .
b. Open references.
c. Remove Microsoft.SharePoint.ApplicationPages from references list.
d. Right click on the references and select Add reference.
e. On Add reference pop up select brows tab and brows to any SharePoint web application (You can find them under     inetpub/wwwroot/wss/VirtualDirectories) and find Microsoft.SharePoint.ApplicationPages.dll under _app_bin (e.g C:\inetpub\wwwroot\wss\VirtualDirectories\81\_app_bin)
f.  Click ok on add reference.

6. Build the solution (At this point you should be able to get a correct build).

7. Change the references to Microsoft public token in projects.

a. Browse to your bin output directory using Visual Studio Command line 
b. Use sn.exe to find out the public token of your dlls (all of them should have a same public token) here is an example of using SN tool “snT Microsoft.Commerce.Portal.Common.dll”. You will see the public token in the result. Copy this value and save it for further references in the following steps. We will preset this value as [ext-public-token].
c. Search for all references to Microsoft Commerce Server public tokens (“31bf3856ad364e35”) and replace them with your own public token.

i.  Open Find and replace in file, from Edit/Find and replace menu.
ii. Expand the Find Options and check “use” and select Regular expression from the drop down beside it.
iii. Provide the root directory of ext kit in “look in” field (e.g. C:\CommerceSharePointExtensibilityKit).
iv. Check “Include sub-folders” check box .
v.  In “find what” field provide “{Microsoft[.]Commerce[.]Portal.*}{31bf3856ad364e35}”. This regular expression matches all public key tokens which follow a Microsoft.Commerce.Portal.
vi. In “Replace With:” field \1[ext-public-token]. This replaces the second part of match {i.e. 31bf3856ad364e35} with your public token.
vii. Expand result options and uncheck “keep modified files open after replace all” checkbox. (Note that this will make your search replace irrecoverable but save on resources).
viii. Click “Replace all”. If you search in files and provide“{Microsoft[.]Commerce[.]Portal.*}{31bf3856ad364e35}”  you should not find any match.
       Find image

d. In anything staring with Microsoft.Commerce.Portal., replace “Microsoft.Commerce.Portal.” with the name space of your own (e.g. ExtKit.).

i.   As previous step open Find and replace in file.
ii.  Expand the Find Options and uncheck check “use” check box if it is checked.
iii.  Provide the root directory of ext kit in “look in” field (e.g. C:\CommerceSharePointExtensibilityKit).
iv.  Check “Include sub-folders” check box .
v.   In “find what” field provide Microsoft.Commerce.Portal.
vi.  In “Replace With:” field enter “ExtKit” or any name space of your choice.
vii. Expand result options and uncheck “keep modified files open after replace all” checkbox. (Note that this will make your search replace irrecoverable but save on resources)
viii. Click “Replace All”. At this point you should not find any match for Microsoft.Commerce.Portal.  anymore.
ix.  Clean the solution and rebuild the solution.     

Let’s try to deploy our refurbished extensibility kit. Since the Web Parts and components in Commerce Server 2009 Share Point Services share the same feature and web part ID’s, they cannot co-exist in same environment so the Commerce Server solution need to be retracted and replaced with the Web Part Extensibility Kit. To make your SharePoint ready for this you need to:

1. Open SharePoint central administration site with administrator level privilege.

2. Click on Operations tab.

3. Click on Solution Management under Global Configuration.

4. If you have microsoftcommercewebparts.wsp in the solution list.

a. Delete any web application that microsoftcommercewebparts.wsp is deployed to:

i.  Click on the Application Management and find “Delete web application” under the SharePoint Web Application Management.
ii. Select dependant applications one by one and delete them .
iii. On Delete Web Application page select both delete content databases and IIS web sites.

b. Retract microsoftcommercewebparts.wsp.

i.  Go to Solution Management and on “Solution Management” page click on microsoftcommercewebparts.wsp.
ii. On Solution Properties click on retract solution.
iii. On Retract Solution page accept the defaults and click OK.
iv. Wait till the status of microsoftcommercewebparts.wsp changes to not deployed.
v.  On Solution Properties click on remove solution to remove the solution completely.

c. Retract microsoftcommercemossdefaultsite.wsp by repeating the same steps as above.

Now we are ready to deploy the Web Part Extensibility Kit:

1. Back up the original WSP files “MicrosoftCommerceMOSSDefaultSite.wsp” and “MicrosoftCommerceWebParts.wsp” in “C:\Program Files\Microsoft Commerce Server 2007\Microsoft Commerce Server 2009\Site”.

2. Replace the original WSP files -“MicrosoftCommerceMOSSDefaultSite.wsp”, and “MicrosoftCommerceWebParts.wsp – with those Generated in previous step. These files can be found in [Unpacked Extensibility Kit directory]\bin\Debug\WSP.

3. Run “SharePointCommerceServicesConfiguration.exe” to deploy a new site in SharePoint.

a. On SharePoint Commerce Services Configuration Wizard select commerce share point default website and web parts and click next.
b. On second page click the button beside Web Application drop down to create a new application.
c. Use port 81 for the NTLM site and 82 for FBA site.
d. Select “Create a new app pool” and provide  appropriate user information. (This user need to have all required permissions as described in Commerce Server 2009 installation guide ).
e. When the new Web Application is generated select it from the Web Application dropdown.
f.  Use default for the other options.


g. Click next and continue with the wizard till it is finished. You may get error at this stage because preparing project that has been done 
    in step 4 is manual and you might have missed one of the projects in this. [You will need to get the address to log files for error analysis].
h. After successful installation of the site click on view site on SharePoint Commerce Services configuration wizard and:

i.   Go to Site Action/View All site Content and click on Channel configuration.
ii.  Enter “Default” as the value for Channel item.
iii. Enter “Adventure Works Catalog” as the value for Default Catalog.
iv. Go to Site Action/Site Settings/ Modify All Site Settings.
v.  On site settings click on Advanced Permission, click on More on the left Nav and then click on Registered User Group.
    Add SigendInClient to this group. Click on New.

As you can see here the above process is completely mechanical and by using an appropriate GREP tool can be automated completely. Another point to note here, if you are planning to customize it always make sense to have separate SharePoint solution which contains all your customization and reference the objects and features in your prepared Extensibility Kit. Doing that you will save yourself from extensive and hard code mergers should you update to a new version of Web Part Extensibility Kit.

Comments (0)