In 3.0 we introduced the concept of installers to make sure that both infrastructure and endpoint specific artifact installed and configured automatically for you if needed.
The installers comes in two flavors, infrastructure installers and regular installers.
Infrastructure installers are used for things that are not specific to a given endpoint e.g. RavenDB, MSMQ.
Regular installers are focused on setting up things that the current endpoint is depending on e.g.. queues, folders, databases etc.
Infrastructure installers are always invoked before regular installers. Although the installers are mainly used internally you could use the for your own purposed as well. Perhaps you need to make sure folders are created, database scripts invoked etc etc.
To create your own installer is as easy as implementing the INeedToInstallInfrastructure<T> interface.
The generic parameter gives you a way to restrict your installer to a specific platform.
Currently this is either Windows or Azure.
If you don’t care about the environment use the INeedToInstallInfrastructure interface instead. To create a regular installer you just implement the INeedToInstallSomething<T> interface again using the T to restrict it to a specific environment.
NServiceBus will scan the assemblies in the runtime directory for installers so you don’t need any code to register them.
When are they invoked?
When using the NServiceBus host installers are invoked as follows:
|Command Line Parameters||Infrastructure||Regular|
As you can see the installers are controlled by both the /install command line option to the host and the current profile used. You can of course implement your own profile if you have other requirements.
When self hosting NServiceBus you have to invoke the installers manually using:
A full example can be found here.
Finally there is one final way to run the infrastructure installers. If you invoke the host with the /installInfrastructure flag the host will run only the infrastructure installers for you without requiring you to configure anything. This can be useful when you setup a new server or a developer machine since that verifies and installs the required infrastructure for NServiceBus to run. The RunMeFirst.bat included in the download is doing just that.