isual Studio setup projects provide a quick and easy way for end-users to deploy your application, whether it is a Web site, Windows NT service, smart client, or Web service. Even though the .NET framework introduced the idea of "xcopy deployment," for many projects it is useful (or expected) that you automate all the tasks required by your installation procedure, thus ensuring the consistency and repeatability of the installation process. When you do that, system administrators and end users gain the ability to perform the installation process without technical assistanceand you avoid the need to provide detailed end-user documentation on the process.
A standard Visual Studio setup project can copy files and create directories on the target file system, create start menus, and create registry entries. If you need to do more, you may need to implement custom actions.
MSI Custom Installer Actions
Since the release of the Windows Installer component, most third-party (and Microsoft) setup-creation tools make use of it as a common base of functionality. Windows Installer setups allow developers to execute both standard actions and custom actions as part of a setup sequence.
You use custom actions when you need to perform special or application-specific tasks that standard actions cannot accomplish. The .NET framework exposes the custom actions capability via the Installer class, whose methods you override to perform tasks of your choice.
Create Your Own Custom Action in .NET
|Author's Note: The techniques shown in this article work with the .NET framework 1.0 or 1.1 and Visual Studio. The code samples were written using Visual Studio 2003 and .NET 1.1
To add a custom action to your setup project, you need to:
- Create an installer class.
- Override the Install and Uninstall methods.
- Test your installer class implementation using the .NET installer utility.
- Configure your setup project to use your custom installer.