This project is read-only.

Installing dependent modules

Topics: Writing modules
May 30, 2011 at 11:32 PM

Hi there,

I am making a module which depends on Contrib.Profile.

I have created the following file: Recipes/extendedregistration.recipe.xml

<?xml version="1.0"?>
    <Name>Install dependent modules</Name>
    <Description>Ensures dependent modules are installed.</Description>
    <Author>Santiago Burbano</Author>

  <Module packageId="Orchard.Module.Contrib.Profile" version="1.1"/>
  <Feature enable="Contrib.Profile" />


When I install my module from the local nupkg file and I select the above recipe to be executed during installation, the Contrib.Profile module is installed.
I see that the installed version corresponds to 1.1 which seems to be the latest one (and is also the recommended one).

However I get a waning in the notification area:

"Some features need to be upgraded: Contrib.Profile "

The profile feature has a red background and shows an Update link.

Why is this?? Any ideas?



May 31, 2011 at 8:21 PM

You also need a Migration step in your recipe:

<Migration features="Contrib.Profile"/>
May 31, 2011 at 9:51 PM

thx! That did the trick. Contrib.Profile dependency is now installed perfectly.

After installing my package and running the recipe I get this notification message:

"Post installation steps failed with error: Sequence contains no matching element"

My feature is not enabled. However I can enable it manually and it all works well!
That message was there before, but I assumed it was due to the problem with the dependent Contrib.Profile module.
Any idea what the problem could be?

I am all set to publish my module, just need to sort this last problem out.

Anyhow, below you find my Module.txt file. Code is on codeplex at:

Name: Extended Registration
AntiForgery: enabled
Author: Santiago Burbano
Version: 1.0.5
OrchardVersion: 1.0
Description: Description for the module
Dependencies: Contrib.Profile, Orchard.jQuery
        Description: Displays any parts added to User Content Type in the Registration Page.
		Category: Social
        Dependencies: Contrib.Profile, Orchard.jQuery

May 31, 2011 at 9:58 PM

Maybe unrelated but the formatting of that manifest looks weird (category in particular).

May 31, 2011 at 10:15 PM

I don't think the error is related to Module.txt

I just did this:

launched a brand new site.
Installed Contrib.Profile from the Gallery.
Installed my module from local nuget file.
This time I did not choose to run the recipe.
No error message.

Error must therefore be recipe related. At least as far as I can tell.


Jun 1, 2011 at 2:04 AM
Edited Jun 1, 2011 at 2:10 AM


I could not find anything wrong, so I went ahead and installed the nuget package running the orchard source (v1.1.30).
This actually seems to be a bug in Orchard.
The problem is in: Orchard.Environment.Features.FeatureManager.EnableFeature
In it the getDisabledDependencies callback is defined. When it is called it has the currentFeatureId passed in as: 'itWORKS.ExtendedRegistration'. This feature has a dependency on 'Contrib.Profile', however the 'Contrib.Profile' feature is NOT available in the featuresState dictionary. Therefore the following call throws an exception:


 // Retrieve disabled dependencies for the current feature
                        return feature.Key.Dependencies
                            .Select(fId => featuresState.Single(featureState => featureState.Key.Id == fId))
                            .Where(featureState => !featureState.Value)
                            .ToDictionary(f => f.Key, f => f.Value);

With my little understanding of orchard it seems that the recipe to download and install the 'Contrib.Profile' module is queued: _recipeScheduler.ScheduleWork(executionId);
But the EnableFeature is called before the scheduled work could actually execute.
Maybe the fix is to have an Event fire when the _recipeScheduler has completed an execution and only enable the feature from within that callback. 

That explains why it all works, when Contrib.Profile has been installed previously.
Hope this sheds some more light on the problem.
The problem is very easy to reproduce with my nuget package. If you need the file just let me know.
If it helps my code is available at: 

Jun 1, 2011 at 2:09 AM
Edited Jun 1, 2011 at 2:10 AM

Please file a bug then.