Activating selected Features during the deployment of a package in Visual Studio 2010 SharePoint Developer Tools

, , , , ,

By default the new Visual Studio 2010 SharePoint Developer Tools activate all Features from the package that is being deployed. While this is a great productivity feature when you need to quickly deploy something, it might be not the thing that you want while working with larger projects. The alternative available out of the box is not activating Features at all. Where does that takes us? I wrote about it previously. In my previous post I also suggested you could use Post-deployment Commands to activate the Features that you want. But wouldn’t it be just more convenient and intuitive if you could select Features that you want to activate during the deployment process? Proudly presenting: Mavention Activate Selected Features extension.

Mavention Activated Selected Features is a custom extension for the new Visual Studio 2010 SharePoint Developer Tools. Upon installation it adds the Select Features to activate… option to the project menu:

'Select Features to activate' menu item highlighted in the context project menu

Clicking on that menu option will open a dialog which allows you to select Features that will be activated during the deployment process:

'Select Features' dialog showing Features from the current Package

As you might have noticed the dialog shows not only the Features from the current project but all Features included in the current Package, which is exactly what you see in the Package Designer.

The Select Features dialog also allows you not only to select Features which will be activated during the deployment process, but also gives you the ability to set the order in which the Features are going to be activated. This might be important if you have for example a hidden Feature that depends on another Feature (Activation Dependencies are not supported for hidden Features).

Once you’re ready selecting the Features you can go and configuring the Deployment Configuration in Project Properties.

Mavention Activate Selected Features extension ships with a custom Deployment Step called Activate selected Features which activates Features just as configured in the previous step. In order to use it, you can either create a new Deployment Configuration or include the Activate selected Features step in your existing configuration.

Custom Deployment Configuration with the Activate Selected Features Deployment Step

Once you’re done with configuring the deployment process you can click Deploy from the project menu. In the output window you can see that only our two selected Features have been activated but also that they have been activated in exact same order as specified in the Select Features dialog.

Visual Studio 2010 Output Window showing the log of the deployment process

Mavention Activate Selected Features is a free extension for the new Visual Studio 2010 SharePoint Developer Tools. This is the first – beta release of the extension. Both final release and the source code will be soon available as a part of the Community Kit for SharePoint: Development Tools Edition (CKS:DEV) toolset.

Download: Mavention Activate Selected Features from Visual Studio Gallery (51KB, VSIX)


Possibly related posts

13 Responses to “Activating selected Features during the deployment of a package in Visual Studio 2010 SharePoint Developer Tools”

  1. Tweets die vermelden Activating selected Features during the deployment of a package in Visual Studio 2010 SharePoint Developer Tools - Waldek Mastykarz -- Topsy.com Says:

    [...] Dit blogartikel was vermeld op Twitter door Waldek Mastykarz, Planet SharePoint. Planet SharePoint heeft gezegd: Waldek Mastykarz: Activating selected Features during the deployment of a package in Visual Studio 2010 # http://planetsharepoint.org/1a993e [...]

  2. Jeremy thake Says:

    again, was wondering why this wasn't just out of the box ;-) AWESOME!

  3. Waldek Mastykarz Says:

    @Jeremy: thanks man. Oh and don't forget to ping me if you have any feedback :D

  4. Mihail Says:

    I get this error by Clicking "Select Features to activate…" button:

    Unhandled exception occurred while calling method 'configureFeaturesActivationMenuItem_Click' of type 'Mavention.VisualStudio.SharePoint.ActivateSelectedFeaturesProjectExtensions, MaventionActivateSelectedFeatures.Implementation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Exception: System.ArgumentNullException. Message: Value cannot be null.
    Parameter name: source

  5. Lluís Says:

    Hey Mihail, i am having same problem with this component, is complaining about the PublicKeyToken, so i checked my token value in the template.xml of the unique featurei have in the project, qich by the way was full O O, i will recheck everything, let's see if we can find the error.

    Cheers!!

  6. Sachin Dekate Says:

    I am getting following error…

    Unhandled exception occurred while calling method 'configureFeaturesActivationMenuItem_Click' of type 'Mavention.VisualStudio.SharePoint.ActivateSelectedFeaturesProjectExtensions, MaventionActivateSelectedFeatures.Implementation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Exception: System.ArgumentNullException. Message: Value cannot be null.
    Parameter name: source

  7. EL Topo Says:

    Great idea for extension. Too bad it does not work :(
    I am receiving the same exception as Michail and Sachin when clicking 'Select features to activate'. Any chance that you could check and fix this problem? Or maybe you could just post the source code, so we could diagnose and fix the problem for ourselves?

  8. El Topo Says:

    Dear Waldek,

    I took the liberty of analyzing your vsix package 'Activating Selected Features'. It turns out there is a bug in method FillFeaturesPicker from class FeaturesPickerDialog. You miss checking selectedFeaturesIds for null before running Count(). This throws an exception when there is no Mavention_FeaturesSelectedForActivation project property specified. Here is a proposed version after the fix:

    private void FillFeaturesPicker(IEnumerable featuresFromPackage, IEnumerable selectedFeaturesIds)
    {
    List source = new List(featuresFromPackage);
    List list2 = null;
    if (selectedFeaturesIds != null)
    {
    list2 = new List(selectedFeaturesIds.Count());
    using (IEnumerator enumerator = selectedFeaturesIds.GetEnumerator())
    {
    Func predicate = null;
    Guid featureId;
    while (enumerator.MoveNext())
    {
    featureId = enumerator.Current;
    if (predicate == null)
    {
    predicate = delegate(SharePointProjectFeature f)
    {
    return f.Feature.Id.Equals(featureId);
    };
    }
    SharePointProjectFeature item = source.Cast().Where(predicate).FirstOrDefault();
    if (item != null)
    {
    list2.Add(item);
    source.Remove(item);
    }
    }
    }
    }
    this.featuresPicker.SelectedItems = list2;
    this.featuresPicker.AvailableItems = source;
    this.featuresPicker.SelectedItemsLabel = "Features to activate:";
    this.featuresPicker.AvailableItemsLabel = "Features in the package:";
    }

    It would be great, if you could fix the code and repost the package on code gallery, as the extension is highly useful.

    Best Regards

  9. Waldek Mastykarz Says:

    @El Topo: Thank you for sending the fix. I will try to add the fix as soon as possible and release a new version.

  10. Mavention Activate Selected Features v1.1 - Waldek Mastykarz Says:

    [...] I’ve just published a new version of the Mavention Activate Selected Features extension with a bugfix for the issue that occurred while trying to open the dialog with new SharePoint projects. [...]

  11. Martin Buus Says:

    Hi
    Thanks for this awesome extension! It's a lifesaver when having features with featurereceivers which adds content on activation ;) Normally the content would be add x times the feature was activated…

    BR
    /Martin

  12. Roland Oldengarm Says:

    Thanks man, this really helped me out!!!
    Only thing: In the Project context menu I see "Menu Command" as title instead of the correct title :) Took me a second longer to find it :)

  13. Waldek Mastykarz Says:

    @Roland: You're welcome. The 'Menu Command' thingy is a Visual Studio bug. Hope it will get fixed in 11.

Leave a Reply

Security Code:

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS
Copyright © 2007 - 2012 Waldek Mastykarz

Creative Commons License