I am attempting to use the Windows Installer. I want to load an empty database (Jet) if and only if an existing copy of the file does not exist. This will allow me to upgrade without losing the file. Presently, the file always loads, even if the file already exists.
- 1) Where is documentation on how to do this (if any)?
- If no documentation is available, are there any examples available?
In .NET, you have a new project type called Setup Project, which generates Windows Installer setup files. The project supports Launch Conditions, which are divided in Search Target Machine (a search in the registry or a search for a file), and Launch Conditions (yes, again). The searches can be stored in sort of "environment" variables that can be checked in the subsequent launch conditions checks. This is a good place to search for the file you want to preserve and maybe stop installation of the DB (if it's a separate MSI).
On the other hand, a more flexible approach is using Custom Actions, which are regular .NET executables or DLLs that perform any arbitrary task (in your case, check for a file and copy a fresh one from a temporary location if it doesn't exist, for example). You can even pass arguments to the assembly, such as the installation folder selected previously or any other value collected through custom fields during installation.
A straightforward article about this is located at http://www.fawcette.com/vsm/2002_11/online/ferracchiati/default_pf.asp. But, of course, the first location for help is the product documentation itself.
Dig Deeper on C# programming language
Related Q&A from Daniel Cazzulino
Here Daniel Cazzulino explains how to load a DSL (domain specific language) domain model instance file programmatically. This requires the .NET type ... Continue Reading
Here we offer a glimpse at 12 of .NET development expert Danny Cazzulino's top ASP.NET questions and answers. Continue Reading
C# developers should NOT be modifying InitializeComponent method in the code-behind (or any of the variable definitions) by hand. Continue Reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.