“The perfect plugin architecture” has become a bit of an obsession of mine. Over the last few years I’ve tried many different things to create “pluggable” apps.
When architecting a plugin system it’s easy to get hung up on exactly what a plugin is. A plugin is just something we are adding to our application. In most cases the plugin will enhance the application, either functionally or aesthetically. It may be a simple css file or a compiled dll.
One of the more challenging aspects of creating a pluggable application use to be how to discover and load our plugins at runtime. However, tools like StructureMap make this a piece of cake.
An area that has not got any easier (until very recently) is how to package, deploy and install plugins. That was until NuGet was released.
NuGet (originally called NuPack) was one of the best things that I think came out of Microsoft/the .NET Community last year. Finally we have a standardised way to package up our libraries and add them to our projects. It covers all the bases – packaging, publishing, versioning, dependency resolution and ships with both GUI and Command line tools.
We’re busy working on the new version of nopCommerce and have been discussing how we can make it more pluggable. Since it is an open source project, if we were to roll our own plugin system we would need:
1 – An open, standard format for packaging and describing plugins
2 – An easy way of advertising available plugins on the nopCommerce website
3 – Allow nopCommerce users to easily and install plugins within their nopCommerce site
4 – Allow additional vendors to create and advertise their plugins
So after looking at what NuGet does and what we need from a plugin system, why would we roll our own??!
What’s more, a web based NuGet package manager already exists inside Web Matrix:
Here I have it connected to my local package source. Neat!
The only problem is, this code isn’t available, so I’m going to do my best to roll my own as I simply refuse to reinvent the wheel!
I would recommend checking out this post by Phil Haack where he uses NuGet.Core to build a self updating asp.net mvc website. It’s along the lines of what I want to achieve here but the source code has not been released (yet??).
A common solution for building pluggable web applications would be such a big hit in the .net community. Having worked with open source projects like nopCommerce, mojoPortal and blogEngine it seems like everyone is striving to do the same thing, so lets put our heads together.
Some NuGet resources I’ve found useful: