/// <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> /// 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); } } } }