Example #1
0
        public Project(string templateDirectory,
                       string databaseFileName, string manufacturer,
                       string productName, string productVersion,
                       string targetDirectoryRoot, string targetDirectory,
                       string packageCode, string productCode, string upgradeCode)
        {
            string source = templateDirectory;

            if (!source.EndsWith(@"\"))
            {
                source += @"\";
            }

            File.Copy(source + "schema.msi", databaseFileName, true);
            m_db = new Database(databaseFileName, Database.OpenMode.Transact);
            Merge(source + "Sequence.msi");
            Merge(source + "UISample.msi");

            using (SummaryInformation si = m_db.SummaryInformation(9))
            {
                si.Title    = "Installation Database";
                si.Subject  = productName;
                si.Author   = manufacturer;
                si.Comments =
                    "This installation database contains the " +
                    "logic and data needed to install " + productName;
                si.Revision = packageCode;
                DateTime timestamp = DateTime.Now;
                si.Printed     = timestamp;
                si.Created     = timestamp;
                si.Saved       = timestamp;
                si.Application = "izfree Tools for Windows Installer 2.0";
                si.Persist();
            }

            using (View view = m_db.OpenView(
                       "INSERT INTO `Property`(`Property`,`Value`) VALUES (?,?)"))
            {
                SetProperty(view, "Manufacturer", manufacturer);
                SetProperty(view, "ProductCode", productCode);
                SetProperty(view, "ProductName", productName);
                SetProperty(view, "ProductVersion", productVersion);
                SetProperty(view, "UpgradeCode", upgradeCode);
                view.Close();
            }

            using (View view = m_db.OpenView("INSERT INTO `Directory`(" +
                                             "`Directory`,`Directory_Parent`,`DefaultDir`) VALUES (?,?,?)"))
            {
                SetDirectory(view, "TARGETDIR", "", "SourceDir");
                SetDirectory(view, targetDirectoryRoot, "TARGETDIR", ".");
                SetDirectory(view, "APPDIR", targetDirectoryRoot,
                             IzFree.Application.WIFileName(targetDirectory) + ":.");
                view.Close();
            }

            using (View view = m_db.OpenView("INSERT INTO `Feature`(" +
                                             "`Feature`,`Feature_Parent`,`Title`,`Description`," +
                                             "`Display`,`Level`,`Directory_`,`Attributes`)" +
                                             "VALUES " +
                                             "('All', '', 'All Features'," +
                                             "'All features in " + productName +
                                             ".', 10, 1, 'APPDIR', 0)"))
            {
                view.Execute();
                view.Close();
            }
            m_db.Commit();
            m_filename = databaseFileName;
        }