コード例 #1
0
        /// <summary>
        /// Loads the banner image.
        /// </summary>
        /// <param name="database">The MSI database.</param>
        private void LoadBannerImage(InstallerDatabase database)
        {
            // Try to open the Banner
            if (msi.banner != null)
            {
                string bannerFile = Path.Combine(Project.BaseDirectory, msi.banner);
                if (File.Exists(bannerFile))
                {
                    Log(Level.Verbose, "Storing banner '{0}'.", bannerFile);

                    using (InstallerRecordReader reader = database.FindRecords("Binary", new InstallerSearchClause("Name", Comparison.Equals, "bannrbmp"))) {
                        if (reader.Read())
                        {
                            // Write the Banner file to the MSI database
                            reader.SetValue(1, new InstallerStream(bannerFile));
                            reader.Commit();
                        }
                        else
                        {
                            throw new BuildException("Banner Binary record not found in template database.",
                                                     Location);
                        }
                    }
                }
                else
                {
                    throw new BuildException(string.Format(CultureInfo.InvariantCulture,
                                                           "Unable to open banner image '{0}'.", bannerFile), Location);
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Loads the license file.
        /// </summary>
        /// <param name="database">The MSI database.</param>
        private void LoadLicense(InstallerDatabase database)
        {
            if (msi.license != null)
            {
                // Find the License control
                using (InstallerRecordReader recordReader = database.FindRecords("Control", new InstallerSearchClause("Control", Comparison.Equals, "AgreementText"))) {
                    if (recordReader.Read())
                    {
                        string licFile = Path.Combine(Project.BaseDirectory, msi.license);
                        Log(Level.Verbose, "Storing license '{0}'.", licFile);

                        // make sure license exists
                        if (!File.Exists(licFile))
                        {
                            throw new BuildException(string.Format(CultureInfo.InvariantCulture,
                                                                   "License file '{0}' does not exist.", licFile),
                                                     Location);
                        }

                        StreamReader licenseFileReader = null;
                        try {
                            licenseFileReader = File.OpenText(licFile);
                        } catch (IOException ex) {
                            throw new BuildException(string.Format(CultureInfo.InvariantCulture,
                                                                   "Unable to open license file '{0}'.", licFile),
                                                     Location, ex);
                        }

                        try {
                            recordReader.SetValue(9, licenseFileReader.ReadToEnd());
                            recordReader.Commit();
                        } finally {
                            licenseFileReader.Close();
                        }
                    }
                    else
                    {
                        throw new BuildException("Couldn't find AgreementText Control in template database.",
                                                 Location);
                    }
                }
            }
        }
コード例 #3
0
        /*
         * Common code for the two tasks
         */

        /// <summary>
        /// Sets the sequence number of files to match their
        /// storage order in the cabinet file, after some
        /// files have had their filenames changed to go in
        /// their own component.
        /// </summary>
        /// <param name="database">The MSI database.</param>
        /// <param name="LastSequence">The last file's sequence number.</param>
        protected void ReorderFiles(InstallerDatabase database, ref int LastSequence) {
            if (!Directory.Exists(TempFolderPath))
                return;

            string[] curFileNames = Directory.GetFiles(TempFolderPath, "*.*");

            LastSequence = 1;

            foreach (string curDirFileName in curFileNames) {
                using (InstallerRecordReader reader = database.FindRecords("File", 
                        new InstallerSearchClause("File", Comparison.Equals, Path.GetFileName(curDirFileName)))) {

                    if (reader.Read()) {
                        reader.SetValue(7, LastSequence.ToString());
                        reader.Commit();
                        LastSequence++;
                    } else {
                        throw new BuildException("File " +
                            Path.GetFileName(curDirFileName) +
                            " not found during reordering.");
                    }
                }
            }
        }
コード例 #4
0
        private void RemoveControlEvent(InstallerDatabase database, MSIControlEvent controlEvent) {
            // Search for a record using all required attributes
            using (InstallerRecordReader reader = database.FindRecords("ControlEvent", 
                       new InstallerSearchClause("Dialog_", Comparison.Equals, controlEvent.dialog),
                       new InstallerSearchClause("Control_", Comparison.Equals, controlEvent.control),
                       new InstallerSearchClause("Event", Comparison.Equals, controlEvent.name),
                       new InstallerSearchClause("Argument", Comparison.Equals, controlEvent.argument),
                       new InstallerSearchClause("Condition", Comparison.Equals, controlEvent.condition))) {

                if (reader.Read()) {
                    // If the record is found, delete it
                    reader.DeleteCurrentRecord();
                } else {
                    throw new BuildException(string.Format(CultureInfo.InvariantCulture, 
                        "ControlEvent not found for removal: Dialog={0}, Control={1}, Event={2}, Argument={3}, Condition={4}.",
                        controlEvent.dialog, controlEvent.control, controlEvent.name, controlEvent.argument, controlEvent.condition), Location);
                }
            }
        }
コード例 #5
0
        private void RemoveDialogControl(InstallerDatabase database, MSIControl control) {
            // Search for a record using all required attributes (even though Dialog_ and Control would suffice)
            using (InstallerRecordReader reader = database.FindRecords("Control", 
                       new InstallerSearchClause("Dialog_", Comparison.Equals, control.dialog),
                       new InstallerSearchClause("Control", Comparison.Equals, control.name),
                       new InstallerSearchClause("Type", Comparison.Equals, control.type),
                       new InstallerSearchClause("X", Comparison.Equals, control.x),
                       new InstallerSearchClause("Y", Comparison.Equals, control.y),
                       new InstallerSearchClause("Width", Comparison.Equals, control.width),
                       new InstallerSearchClause("Height", Comparison.Equals, control.height),
                       new InstallerSearchClause("Attributes", Comparison.Equals, control.attr))) {

                if (reader.Read()) {
                    // If the record is found, delete it
                    reader.DeleteCurrentRecord();
                } else {
                    throw new BuildException(String.Format(CultureInfo.InvariantCulture, 
                        "Control not found: Dialog={0}, Control={1}. One or more of the required attributes do not match.",
                        control.dialog, control.name), Location);
                }
            }
        }
コード例 #6
0
        /// <summary>
        /// Loads the banner image.
        /// </summary>
        /// <param name="database">The MSI database.</param>
        private void LoadBannerImage(InstallerDatabase database) {
            // Try to open the Banner
            if (msi.banner != null) {
                string bannerFile = Path.Combine(Project.BaseDirectory, msi.banner);
                if (File.Exists(bannerFile)) {
                    Log(Level.Verbose, "Storing banner '{0}'.", bannerFile);

                    using (InstallerRecordReader reader = database.FindRecords("Binary", new InstallerSearchClause("Name", Comparison.Equals, "bannrbmp"))) {
                        if (reader.Read()) {
                            // Write the Banner file to the MSI database
                            reader.SetValue(1, new InstallerStream(bannerFile));
                            reader.Commit();
                        } else {
                            throw new BuildException("Banner Binary record not found in template database.",
                                Location);
                        }
                    }
                } else {
                    throw new BuildException(string.Format(CultureInfo.InvariantCulture, 
                        "Unable to open banner image '{0}'.", bannerFile), Location);
                }
            }
        }
コード例 #7
0
        /// <summary>
        /// Loads the license file.
        /// </summary>
        /// <param name="database">The MSI database.</param>
        private void LoadLicense(InstallerDatabase database) {
            if (msi.license != null) {
                // Find the License control
                using (InstallerRecordReader recordReader = database.FindRecords("Control", new InstallerSearchClause("Control", Comparison.Equals, "AgreementText"))) {
                    if (recordReader.Read()) {
                        string licFile = Path.Combine(Project.BaseDirectory, msi.license);
                        Log(Level.Verbose, "Storing license '{0}'.", licFile);

                        // make sure license exists
                        if (!File.Exists(licFile)) {
                            throw new BuildException(string.Format(CultureInfo.InvariantCulture,
                                "License file '{0}' does not exist.", licFile),
                                Location);
                        }

                        StreamReader licenseFileReader = null;
                        try {
                            licenseFileReader = File.OpenText(licFile);
                        } catch (IOException ex) {
                            throw new BuildException(string.Format(CultureInfo.InvariantCulture,
                                "Unable to open license file '{0}'.", licFile), 
                                Location, ex);
                        }

                        try {
                            recordReader.SetValue(9, licenseFileReader.ReadToEnd());
                            recordReader.Commit();
                        } finally {
                            licenseFileReader.Close();
                        }
                    } else {
                        throw new BuildException("Couldn't find AgreementText Control in template database.", 
                            Location);
                    }
                }            
            }
        }