Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'm building a complex application that is composed by multiples features of different kind.

I want to avoid having all features individually able to be activated from the site admin page.

What my options (Sandboxed solution is not available) ?

I can see three solutions, all consisting in hiding features (HIDDEN=true) :

  • Activate all features from a PS script
  • Create a custom site template, and specify all features in the onet.xml. This will breaks features stappling I fear
  • Create a "Master" feature, visible, that only performs other features activation

What is the best solution ? Is there any other solution I missed ?

ps: sp 2010 enterprise

share|improve this question
add comment

3 Answers

up vote 3 down vote accepted

I like the idea of hiding all of your features and having one un-hidden feature that activates the hidden ones.

share|improve this answer
add comment

I do this all the time and have even written my own SPFeatureReceiver class to streamline the creation of such features.

The workhorse of the class though is really just this:

foreach (Guid id in FeatureGuids)
{
    if (oWeb.Features[id] == null)
    {
        oWeb.Features.Add(id);
    }
}

Where FeatureGuids is just a list of web scoped feature GUIDs (The guid can be found in the feature manifest file). SPSite also has a features collection that you can do this on.

share|improve this answer
add comment

Of course, one might ask the question why you're breaking it up into many features if they are all dependant on each other and hidden - Why not just deploy them as a single feature? There's no requirement to have different things in different features (Except where they have to be deployed at different levels - farm/webapp/site/web).

But, if you must do it like this, do ensure that the solution/feature dependancies are defined. Scripting or having a 'master' feature would be down to your preference - I'm not aware of any best practise regarding this (although I would probably script the feature activation myself).

share|improve this answer
    
Marcus, I have to split into several features for two reasons: mainly because of the different scopes of features (site and web), and sometimes because of the <s>awful</s> lookup definitions between several of my list –  Steve B Jun 7 '12 at 7:19
    
Fair enough. I mention it because I've seen people go crazy in the past (1 feature per artifact).In a project a while ago, the developer had ended up with 30+ features and was wondering why solution deployment was so complicated... –  marcus.greasly Jun 8 '12 at 3:10
    
Solution deployment should still be easy in this respect. All your features should be grouped into solutions (WSPs) where it makes sense. Most of my projects have 2 or 3. One common WSP that I reuse in all projects and one or two that are project specific. –  ToddersLegrande Jun 12 '12 at 11:37
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.