Navigation

Thursday 15 April 2010

How my Module feature broke the Publishing Feature

So .. there I was in SharePoint 2010, working on a new corporate website in Visual Studio 2010.

We decided we needed some image assets to be provisioned, so I decided to make use of some of the new features of VS2010 and created a "Module" SharePoint Project Item.

I added my images, telling to to deploy to RootWebOnly and setting the path as PublishingImages, everything a good SP dev should do...  or so I thought.

Deployed my solution .. blam .. Site Collection dead. I fired up the (quite excellent) ULS Viewer which told me the following error messages:
'Failed to create the 'Images' library.'. Exception was: 'Microsoft.SharePoint.SPException: A list, survey, discussion board, or document library with the specified title already exists in this Web site.
Publishing Feature activation failed. Exception: Microsoft.SharePoint.SPException: Provisioning did not succeed. Details: Failed to create the 'Images' library.
Now this was instant brown trousers time ... the Publishing Feature was broken!!! (or so I thought).

What had actually happened was brain stunningly simple. You see .. Visual Studio had kindly placed my new Module item into a Site Scoped feature...

The Publishing Feature is Web Scoped...

Now .. hopefully the sharper reader will already have realised the predicament. As I explained in an earlier blog post (onet.xml order of execution) Site Scoped features will activate before web scoped features ... more accurately my Modules feature is trying to place my images into /PublishingImages/ before the document library has been created!!

What it actually did was create a folder in the SPWeb (yes .. you can have SPFolder objects directly within an SPWeb .. you don't need a document library) so when the Publishing feature came along the URL "/PublishingImages" was already in use!

I created a new Web scoped feature for my images module and re-deployed ... everything is now working. (the publishing feature activates first .. creating the image library ... and my images are placed inside it).

*sigh*

Another one to put large and clear on the blackboard of experience!

3 comments:

  1. You're absolutley right.... Such a simple cause, such a simple fix. This time my "turn-straight-google" laziness has paid off.

    Thanks Martin!

    ReplyDelete
  2. Plz help get error : Provisioning did not succeed. Details: Failed to create the 'Pages' library.

    ReplyDelete
  3. raki : you did read the blog post right? Did you try changing your feature to be WEB scoped and not SITE scoped?

    ReplyDelete

This blog has been moved to www.martinhatch.com

Note: only a member of this blog may post a comment.