dotnetInstaller configuration file XML schema

Jun 17, 2010 at 2:35 PM
I would like to somehow automize the creation of the dotnetinstaller configuration xml files for a autobuild process. Therefore it is really helpfull to have the XML schema DNI uses in the Editor for the configuration.xml file. I could not find any in the zip as well as in the sources, so does there exist a XML file or other easy way to get an overview of the config XML layout?
Jun 17, 2010 at 3:12 PM
Edited Jun 17, 2010 at 3:13 PM

The best way is to take InstallerLib.dll and use the classes (starting with ConfigFile) to read/write configuration. You can write an MSBuild task or an executable that does what you need to do. That's what the unit tests do.

            ConfigFile configFile = new ConfigFile();
            SetupConfiguration setupConfiguration = new SetupConfiguration();
            configFile.Children.Add(setupConfiguration);
            ComponentCmd cmd1 = new ComponentCmd();
            setupConfiguration.Children.Add(cmd1);
            cmd1.command = "cmd.exe /C exit /b 0";
            string configFilename = ...;
            configFile.SaveAs(configFilename);

This is nice because the library handles upgrades, you can load a configuration of any version and save as the current one. With new releases of dotNetInstaller you can just drop in a newer DLL and you're done.

Jul 27, 2010 at 1:49 PM
thanks for the information, this seems to work well. The only thing I am asking myself now is, how do I find out which properties in the object I have to set and which are optional or predefined? Is there a way to find this out? Allthough it is not allways clear from objects, which are valid childs for an object (since many objects derive from XMLClass)
Jul 27, 2010 at 2:34 PM

Everything has a default value (empty string is a default value too), but there's no clear way of knowing of what's optional and what's not, nor what's valid and what's not. For example, if you don't define cmdline for a command component, it will fail at runtime. It would be a nice improvement to introduce an attribute and go over all the objects and mark those optional and those required and check the values during save (#6730).

Every node is an XmlClass, but valid children are in a better place. They are indicated by a reflection attribute on the parent node. For example, ConfigFile can only have a WebConfiguration or a SetupConfiguration child.

    [XmlChild(typeof(WebConfiguration))]
    [XmlChild(typeof(SetupConfiguration))]
    public class ConfigFile : XmlClass

XmlClassCollection has a CanAdd method to check the reflection attribute, so you can do configFile.Children.CanAdd(typeof(Download)), for example if you need to find out programmatically.

Jul 27, 2010 at 3:33 PM
thanks for the fast reply and for adding a new feature proposal. I added to have this somehow documented. For the possibilities of what can be added to which objects I do not need this during programm time, but would like to have this during/before compile time to get an error if I add a wrong object type. But I can use the installer editor to find out that quite fast since it is mainly a one time issue (once its in the programm correctly, it might not change very often ;))