The Visual Studio IDE provides a relatively painless way to build MSI files for deployment. The Deployment projects can refer to other projects in the solution to build installation wizards that install the output of a project into a folder, with all of the dependencies and files.
Ideally, the setup for each plug-in should be in a separate MSI file to keep the plug-in truly modular. The following few paragraphs go over creating your own projects for deployment.
To create a deployment project for one of the plug-ins, first open the solution in the Visual Studio IDE. Open the Solution Explorer window from the View menu if it's not already
open. Then highlight the plug-in project in the Solution Explorer that you want to deploy. For the purposes of this example, let's assume you want to deploy the
AuthenticationPlugin.Plugins.LdapAuthenticator project. With the project highlighted, pick Add Project->New Project from the File menu.
In the Add New Project window, pick Setup and Deployment Projects from the Project Types list, and then choose Setup Project from the Templates list. A new project will appear in the solution. Next, you need to add the output of the
AuthenticationPlugin.Plugins.LdapAuthenticator project so you can install it. To add the output of the project, highlight the
LdapAuthenticatorPluginSetup project in the solution explorer and click Add->Project Output from the Project menu. In the Add Project Output Group box, select
AuthenticationPlugin.Plugins.LdapAuthenticator from the Project list and select Primary Output from the list below it. This automatically adds the assembly created by
AuthenticationPlugin.Plugins.LdapAuthenticatorto the setup project, and also adds all the dependencies that the IDE finds.
With only the project output in the setup project, the configuration file that was created in Part 3 will not be deployed with the plug-in. Never fear; other types of files from the project can be added to the
LdapAuthenticationPluginSetup project. To add other files, such as the custom configuration files, highlight the
LdapAuthenticatorPluginSetup project in the solution explorer and again select Add->Project Output from the Project menu. Select the
AuthenticationPlugin.Plugins.LdapAuthenticator project from the list again, but this time select Content Files from the list instead of Primary Ouput. Now, make sure the configuration file is set up as a content file, by changing the properties on
AuthenticationPlugin.Plugins.LdapAuthenticator.dll.config file to use Content as the Build Action property. That's it. When the
LdapAuthenticationPluginSetup project is built, the custom configuration file will be included along with the necessary assemblies.
This article, the last in a four-part series focusing on concepts that can be used to build modular applications using plug-ins, covered logging, a finishing touch that is a useful addition to any application. Two methods of logging exceptions and messages are using the Microsoft Exception Management Application Block, and the log4net framework.
Both the Exception Management Application Block and log4net can be extended to log exceptions and messages to different locations. Unlike the Application Block, log4net lends itself to logging messages that don't only occur inside a try catch block, such as informational or debug messages.
Finally, I covered using the Visual Studio IDE to create deployment projects to deploy some of the plug-ins that I've created throughout the series. The downloadable solution accompanying this article contains a few sample deployment projects that when built install a plug-in and its configuration files.
I hope this four-part series has given you some ideas that will help you deploy a modular, plug-in style application easily. At the very least, I hope you will have picked up some pointers on using reflection, interfaces, XML configuration, logging, and deployment.