I have been receiving the following error when I click deploy in VS using VSeWSS 1.3 (this is a simple deployment to my local development SharePoint):
"Failed to activate feature 'SiteScopeFeature - Fields' (ID: c66d8a1f-b5a6-469d-91f7-79542545a788) at scope 'http://spvm/'"
This is after modifying me features to hell and back to eliminate any possible issues the complex features could have.
So I opened the site in IE and decided to activate the features manually, all activated until the following error occurred:
"Dependency feature 'WebScopeFeature - LookupLists' (id: ef84c085-cabc-4834-a7f1-fcbcf542e1b9) is not properly scoped for feature 'SiteScopeFeature - LookupFields' (id: 14ff1c75-3ce1-4129-9272-f762d80bbafe). Its scope 'Web' must be equal to or higher than 'Site'."
OK! Great thanks for telling me that VSeWSS! NOT! Why could this not be validated during the packaging of the solution? Or at least tell me the actually reason the deployment failed. Instead I have to go look in the SharePoint log files, which is where I found the first clue to the issue, but it's a pain!
I found the following post where somebody else also had a similar problem:
Scope Dependencies for SharePoint Features
So the solution:
Change the scope of the feature it is dependant on to Site? OK, will try that.
Next error (this time from VSeWSS):
"Elements of type 'Receivers' are not supported at the 'Site' scope. This feature could not be installed."
That's not going to work.
I'll make some lunch, think about it and come back to you.
So the situation is that I have a couple of features:
-
A site feature to create the general (non-special) site fields.
-
A site feature to create the general (non-special) content types
-
A web feature which creates the look-up list. (The look-up list will be used in site look-up fields)
-
A site feature which creates the look-up fields referencing the look-up list. (Obviously this feature has to be dependant on the look-up list feature.)
-
A site feature which creates the the more complex content types, containing the look-up fields which references the look-up lists.
The problem:
Feature #4, a site scope feature, is dependant on feature #3, which is a web scope feature. Changing feature #3 to a site scope feature give a error saying that event receivers cannot be activated in a site scope feature.
Find the event receiver (it is on one of the list, not suppose to be), remove it, but add the receiver and the contained code the content type representing the item in the list.
Try again. Still failing, this time with some other strange error, because the content type is being added to the list via the list definition. Why I tell you why?
No worries, get rid of the reference to the content type in the list definition and add it via the object model in the feature receiver.
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
SPSite site = properties.Feature.Parent as SPSite;
using (SPWeb web = site.OpenWeb())
{
SPContentType myItemContentType;
if (web.AvailableContentTypes.CanGetContentType("MyItemContentType", out myItemContentType))
{
SPList list;
if (web.Lists.CanGetList("MyLookupList", out list))
{
list.ContentTypes.Add(myItemContentType);
list.Update();
web.Update();
}
}
}
}
That seemed to work. (Until the next issue pops up...)
I must say it help writing about a problem. One starts thinking about how you came to be in the situation you are currently in and the issues surrounding the problem.
Alternative Solution (the rantings version - don't read this if you are a sensitive SharePoint developer):
Develop using something else than SharePoint... That's the feeling I'm starting to get, since I spend more time trying to figure out why deployments don't work, instead of building the actual solution.
I've found most of my time spent on SharePoint development is not spent and designing the solution, but with the inconsistent xml definitions used in the features definitions. I've been very close to giving up on the xml generated for features and the solution file by VSeWSS, it just feels unworkable. I end up getting ridiculous errors (e.g. "Failed to activate feature 'SiteScopeFeature - Fields' (ID: c66d8a1f-b5a6-469d-91f7-79542545a788) at scope 'http://spvm/'" - WTF!!!! give me more detail!), just when I start getting to a point where I feel I understand how things work and that my features are actually deploying successfully. Every time this happens I have hold myself back, because I don't know what other issues I will be running into switching to using the feature activation event and the SharePoint object model.
I'm sorry but deployment of a solution should not be this difficult (I've not even got to production!!) and this will have to reworked and IMPROVED for SharePoint to become more usable from a developers perspective.
Why is this a common problem in MS products? Things always turn into a nightmare when it comes to deployment of custom solutions to there products.