Activate On Default

When developing SharePoint features, you can set some properties on your features. One of them is called “Activate On Default”:

Now this sounds straight forward, right? Well, it both is and isn’t.

A few days ago, I created a SharePoint solution package with two features. One should create some site columns and content types, the other should manipulate the ribbon in document libraries in a specific site. So I set the content type feature to activate on default and the ribbon feature to not activate on default, as I was going to do this manually.

To my surprise, they were both activated on deployment!

I turns out that this setting only applies to features that are scoped to farm or web application level. If your feature is scoped to site (site collection) level (like my features) or web (site) level, then it doesn’t matter what you select here. Thanks to Christopher Kimbell for this knowledge. In fact, it has little to do with feature activation as part of deployment

So how to specify whether or not your feature should be activated on default when deploying? Well, go to your project properties, click SharePoint, and you’ll see this:

Here you can select “No activation” to stop visual studio from activating your features after deployment. Note that this is an “all or nothing” setting, so either all your features will be activated, or none. And this one does not discriminate based on feature scope, so features scoped to site and web will also be controlled here. To manually activate one of your features, use stsadm (this example is for a site scoped feature)

STSADM.EXE -o activatefeature -name my.feature.name 
-url http://my.domain.com/sites/somesite/

Also note that this last setting is a visual studio deployment setting, while the “activate on default” is a setting for the SharePoint feature. That is, if you create a web application scoped feature and leave the “activate on default” to true (its default setting) and deploy it, every web application you create after that deployment will get this feature turned on. That is probably not what you want, it is much better to activate the features you need explicitly using STSADM or a PowerShell cmdlet.

Also check out the official documentation.

About Øystein Garnes

Software Project Manager, former .Net and SharePoint 2010 developer, husband, Boston Terrier owner, amateur caveman chef, amateur genealogist, cross country skier, food blogger.
This entry was posted in SharePoint and tagged , . Bookmark the permalink.

1 Response to Activate On Default

  1. kewwwa says:

    For site/web scoped features, simply specify web full url in “Site Url” property of the project.
    ex: if “SiteUrl” is set to “http://my.domain.com/sites/somesite/subsite/”, web scoped features will be activated at “http://my.domain.com/sites/somesite/subsite/”, and site scoped features will be activated at “http://my.domain.com/sites/somesite/”

Leave a comment