Module Dependencies in Gallery will crash site

Topics: Troubleshooting, Writing modules
Jun 3, 2011 at 2:04 PM

This is something that affects existing modules, for instance the Voting and Stars module. If you attempt to install Stars without first installing Voting, it takes down your entire site with a compilation error ("Error compiling module "Contrib.Stars" from file "/OrchardLocal/Modules/Contrib.Stars/Contrib.Stars.csproj":")

This also affects me as I'm developing a number of modules which depend on each other. Someone tried to install one without first installing the dependencies and boom ... obviously doesn't give that person either a good impression of my module, or a good impression of Orchard when I explain what the problem is!

It should be pretty simple to at least prevent Orchard attempting to compile a module if its dependencies aren't installed, this would mitigate the problem until there's a way to properly chain install dependencies from the gallery.

Is there already a workitem for this issue or should I raise one?

Jun 3, 2011 at 2:08 PM

Ah, the issue is here: http://orchard.codeplex.com/workitem/17295

Jun 27, 2011 at 12:55 AM
Edited Jun 27, 2011 at 7:12 AM

@randompete,

Is there a best practice for setting up dependencies between modules? I would like to create two modules where one depends on the other and is able to use its models and other code. As you pointed out, setting up an actual code dependency between the projects/assemblies will probably cause compilation errors and bring down your site if the dependent assembly is not present. Is there some fancy dependency injection I'm supposed to use to accomplish this? Perhaps the best thing is to not share any code but just replicate it in both of my modules, or maybe I should combine the two modules into one module containing two features.

Jun 27, 2011 at 12:01 PM

I've just been adding the project references in Visual Studio, and Orchard's dynamic compilation seems to work out the binary dependencies, as long as the requisite modules are there of course. Unfortunately there's no way to force an installation of dependent modules, and if they're not there the missing reference cause a compilation error.

I added recipes to the latest Media Garden releases but they still don't resolve the issue during install from gallery. That's a separate workitem: http://orchard.codeplex.com/workitem/17898

So I think the best practice is to make the recipes readily available; they'll work if the user runs the recipe manually from the dashboard, and then recommend that as the quickest way to install your module.

You could try writing text in your gallery description, like "note: this module requires requires you to install [x] first". Unfortunately, people tend to install things without reading everything first, and the #1 issue I'm having reported is the installation failure.

Jun 27, 2011 at 8:57 PM

OK, great. that's exactly what I needed to know. I wasn't sure if I should be setting up dependencies in VS or if there was some secret DI way of doing it. It sounds like you've had success with the VisualStudio route so I'll give that a shot.

It looks like some day they might support stand-alone recipes in the gallery, which might improve the dependency situation:

http://orchard.codeplex.com/discussions/262960