Home Dashboard Directory Help
Search

Deploying features with activation dependencies (SharePoint development) by JensOtto


Status: 

Closed
 as Duplicate Help for as Duplicate


2
0
Sign in
to vote
Type: Bug
ID: 644470
Opened: 2/16/2011 2:26:08 AM
Access Restriction: Public
1
Workaround(s)
view
0
User(s) can reproduce this bug

Description

Developing SharePoint 2010 solutions in Visual Studio 2010.

There is a problem in Visual Studio when deploying a solution with activationdependencies. Consider the following scenario.

There are two features A and B, both are both site or web scoped. A has an activation dependency on B and B is hidden. When deploying the solution Visual Studio tries to activate both features. First it activates A. This automatically activates B since it's hidden. Then when Visual Studio tries to activate B it failes with the error: "Error occurred in deployment step 'Activate Features': Feature 'B' (ID: <feature id>) is already activated at scope '<site url>'."

This can be solved by installing Mavention Activate Selected Features and selecting only feature A for activation. Visual Studio should however be able to correctly activate features without relying on 3rd party extensions.

The next problem arises when trying to retract or do a second deploy. Visual Studio will again try to deactivate both features. First A is deactivated and because of the activation dependency and that feature B is hidden this will simultaneously deactivate B. When Visual Studio then tries to deactivate B it fails with the error: "Error occurred in deployment step 'Retract Solution': Feature '<feature id>' is not activated at this scope."

Possible solutions that I can think of:
B is deactivated before A. (I have not found a reliable way of controlling the order of deactivation)
B is never deactivated directly by Visual Studio. (I have not found an equivalent of Mavention Activate Selected Features for feature deactivation)
Visual Studio ignores the error caused when the feature is not activated.

Please note that it seems that the order of activation/deactivation sometimes is reversed. If this happens then simply switch the role of feature A and B (set A as hidden, B as visible, and reverse the activationdependency).
Details
Sign in to post a comment.
Posted by Pieter_Veenstra on 11/22/2011 at 5:57 AM
I find the following workaround easier:
1. Disable the autoactivation of features in the Project properties -> SharePoint
2. Start the feature manually in SharePoint.

This workaround only really helps when you don't have too many features to activate, but I found that many of my solutions have a single feature with feature dependencies (=all other features in the solution) activating all other features.
Posted by Microsoft on 3/15/2011 at 8:29 PM
Hi Jens,

The fix is not in VS2010 SP1, but in next version of VS2010. If it blocks you and you want to fix it as soon as possible in VS2010 SP1, please contact our support via the Visual Studio Help and Support page on MSDN.

Thanks,
Xiaoying
Posted by JensOtto on 3/8/2011 at 11:31 PM
Hi

Is this not fixed in VS 2010 SP1? I have installed and testet it, and still have the same problem.

Regards
Jens Otto
Posted by Microsoft on 2/17/2011 at 10:55 PM
Hi there,

Thanks for reporting the issue! We've noticed this bug and fixed it in next release of Visual Studio. If you have further comments, please feel free to let me know.

Thanks,
Xiaoying Guo
Program Manager, Visual Studio Business Applications Tooling
Posted by Microsoft on 2/16/2011 at 2:58 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.
Posted by EzequielE on 6/12/2011 at 6:12 PM
A possible workaround for this would be to configure the project for "No Activation" and activate the features programmatically from the FeatureActivated event.

The remaining issue when doing this is that Visual Studio still tries to deactivate all features anyway which would make it fail on Retract if you have code to deactivate the features. In this case what you can do is on the FeatureDeactivating event use conditional compilation and just execute the deactivating code if the project is not in debug mode like:

#if (DEBUG == false)
// Deactivate feature here.
#endif