Controlling the order of Feature Activation in Visual Studio 2010
(Note – this behaviour was observed in VS 2010 RC .. I haven’t tested yet in RTM)
One of the most challenging things I’ve had to deal with in a long time is trying to work out how to get Visual Studio 2010 to activate my Fields feature before it tries to activate my Content Type feature 🙂
First I was (obviously) getting errors that the field didn’t exist (because it couldn’t find the Field that the FieldRef was pointing at).
Next I tried adding a Feature Activation Dependency, hoping that Visual Studio would intelligently activate them in the order of the dependencies that I setup … WRONG … I am now getting errors saying it cannot activate because the dependency is not active (doh!).
Finally struck upon something .. going to the Package .. the features were being activated in the order they appeared in my VS 2010 Package item.
Unfortunately there is no “move-up”, “move-down” or drag and drop re-ordering, so I had to remove all of the features from the package and then put them back in the correct order of activation.
It seems there ARE move-up / move-down buttons, but they don’t stick to the scrollbar so if you scroll down (to the bottom of the package) you can’t see them anymore. Anyway .. yes you can re-order them .. but you’ll maybe find this slightly more difficult if your features are at the bottom of the package list.
Slightly frustrating, but glad it’s all working now!