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.

UPDATE
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!

  • Phil H.

    Note: I had to restart visual studio and re-open the project before it picked up the change in activation order.

    Thanks for the tip.

  • Anonymous

    thanks man!

  • Alex_B

    Thanks!

  • Shakizat Almenov

    Man! you save my time. thanx

  • Kooseh

    Thank you.

  • Anonymous

    Fuck (Fornication Under Command of the King)
    all Feature Dependency.

    But Thank you man two days i'm strugling with the issue. Thank you. It's working !!!

  • Anonymous

    You save my day!
    Thanks very much!

  • Anonymous

    Thanks a lot 🙂