How does visual studio decide which feature to add an element to? My features have a specific order which they need to be enabled (and its set using Feature Dependencies) but I need a simpler method of managing which feature my items are listed in.

For example I would like lists to be added to a particular feature, list events to another, web parts to another and so on.

  • I have removed the two SharePoint version tags. Short story: we prefer to use them only when the question is version specific. You can refer to this post for further details : link here – SPArcheon Jan 16 '14 at 14:40

When you create an element (for example a module, content type definition etc) Visual Studio attempts to assign it to a feature in your project. Based on my observation, it selects the first appropriate feature he found, with no other background logic than "do not chose a feature that can't contain the current artifact".

After that, you can still reassign the elements between features by using the feature explorer / feature property window that appears when you doubleclick a feature in the solution explorer.

That said, the automagical adding of elements to feature is pretty... loathed by many. Mavention actually built a specific plug-in to disable that behavior, so if you need it you can find it here. I usually use it to avoid forgetting to check the automatic assignments made by Visual Studio but it is only available for VS 2010 (no 2012 version).
If you are working with VS 2012 you could resort using CKS Dev (which you probably use anyway) - it has a similar feature but it seem to have some compatibility problem with TFS and get latest version operations. You can find the plugin here

  • Thanks, the Mavention product doesn't work in VS 2012 but its a useful insight anyway. – Mauro Jan 16 '14 at 14:07
  • then we must call @WaldekMastykarz for a port :P. Anyway.. I seem to remember something similar for VS 2012 - let me have a look. – SPArcheon Jan 16 '14 at 14:24
  • Yep - found in my Waldek folder in the Favorites Links. CKS Dev should be able to replicate the feature, but it has know compatibility problems with TFS. More about that here. – SPArcheon Jan 16 '14 at 14:28

It's you that decides which SPI gets in which feature. In feature designer, on the left box you can see a list of all the available items that you can add to the feature (feature scope is taken into account). You then click on an item and move it to the right box. This is how you add a project item to a feature.

  • I know I can move them, but I'd have preferred to be able to specify them at creation time. – Mauro Jan 16 '14 at 14:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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