/// <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); } } }
/// <summary> /// Checks to see if the specified table exists in the database /// already. /// </summary> /// <param name="TableName">Name of the table to check existance.</param> /// <returns>True if successful.</returns> public bool VerifyTableExistance(string TableName) { using (InstallerRecordReader reader = FindRecords("_Tables", new InstallerSearchClause("Name", Comparison.Equals, TableName))) { return(reader.Read()); } }
/// <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); } } } }
/// <summary> /// Drops the empty tables. /// </summary> /// <param name="isMergeModule">Determines if this is a merge module or not</param> /// <remarks>If it is a merge module, the FeatureComponents table should not be dropped.</remarks> public void DropEmptyTables(bool isMergeModule) { // Go through each table listed in _Tables using (InstallerRecordReader reader = FindRecords("_Tables")) { while (reader.Read()) { string tableName = reader.GetString(0); if (isMergeModule && tableName == "FeatureComponents") { continue; } if (VerifyTableEmpty(tableName)) { // Drop the table ExecuteNonQuery("DROP TABLE `" + tableName + "`"); // Delete entries in _Validation table ExecuteNonQuery("DELETE FROM `_Validation` WHERE `Table` = '" + tableName + "'"); } } } }
/// <summary> /// Checks to see if the specified table is empty. /// </summary> /// <param name="TableName">Name of the table to check existance.</param> /// <returns>True if empy and False if full.</returns> public bool VerifyTableEmpty(string TableName) { using (InstallerRecordReader reader = FindRecords(TableName)) { return(!reader.Read()); } }