Umbraco Packages – Install actions and user control

When you create a package for Umbraco you can specify a user control that will be loaded during the installation. This user control will be shown to the users who installs your package into his/hers Umbraco installation.




You can also add something called “Package Actions”, these are basically small actions that are configured with XML. The package actions can do stuff like adding a new section, adding a tree, adding a dashboard, add xslt/rest extensions and much more. There is actually a community project that extends this even more with a lot of features – have a look at Package Action Contrib.




If you want to take it even further you can also create your own Package Actions that you can call from your package action XML. The implementation of a Package Action is quite simple and straight forward, see this example, the only thing you need is to implement the IPackageAction-interface and put the compiled dll in the bin-folder.


Now – what’s new about this?

Nothing really. But I came to think about one thing today. In which order is everything executed? How does it work? So I came up with this little picture.




1. Copy and create

In the first step all files are copied. It’s both the files that you picked on the “Package Files”-tab when creating your package and the files needed for css, templates, avascript, macros and so on.


2. Package Actions

Next Umbraco loads all the package actions. This is important to notice: it instantiate all the IPackgeAction-classes first and then executes them in the order they are present in the XML-configuration.

So if we our configuration looked like this:


<Action runat="install" undo="true" alias="Action1"></Action>
<Action runat="install" undo="true" alias="Action3"></Action>
<Action runat="install" undo="true" alias="Action2"></Action>

Umbraco would first create an instance of each action and then call the Execute-method on Action1, Action3 and Action2 – in that order.


3. User Control

When this is done Umbraco will show the user control that you configured – if you did not configure a user control a generic message will be shown.



PS. If you like the blog post - please share it =D