Example #1
0
        /// <summary>
        /// Quickly call cabwiz.exe.
        /// </summary>
        /// <param name="iniFile">The inf file object.</param>
        /// <param name="nouninstall">The <see cref="NoUninstall"/> property will be set to this value.</param>
        /// <param name="compress">The <see cref="Compress"/> property will be set to this value.</param>
        /// <returns>The cabwiz.exe exit code. 0 indicates success, a non-zero value indicates failure.</returns>
        public static int QuickRun(InformationFile iniFile, bool nouninstall, bool compress)
        {
            var app = new CabwizApplication();

            app.NoUninstall = nouninstall;
            app.Compress    = compress;

            return(app.Run(iniFile));
        }
Example #2
0
        /// <summary>
        /// Executes and calls cabwiz.exe using the specified inf file.
        /// </summary>
        /// <param name="iniFile">A <see cref="InformationFile"/> to be written to the hard-drive.</param>
        /// <returns>The cabwiz.exe exit code. 0 indicates success, a non-zero value indicates failure.</returns>
        public int Run(InformationFile iniFile)
        {
            if (iniFile == null)
            {
                throw new ArgumentNullException("iniFile");
            }

            iniFile.WriteInformationFile();

            return(this.Run(iniFile.FileName));
        }
Example #3
0
        /// <summary>
        /// Add a directory to a information file, using the specified build profile.
        /// </summary>
        /// <param name="inf">The information file to add the directory to.</param>
        /// <param name="profile">The build profile used.</param>
        /// <param name="directoryInfo">The directory to add.</param>
        /// <remarks>
        ///     <para>
        ///         See <see cref="AddToCabwiz(Cabwiz.InformationFile inf, BuildProfile profile, FileInfo file)"/>
        ///             for information about what files are excluded.
        ///     </para>
        /// </remarks>
        private void AddToCabwiz(Cabwiz.InformationFile inf, BuildProfile profile, OutputDirectoryInfo directoryInfo)
        {
            foreach (var subDirectory in directoryInfo.SubDirectories)
            {
                this.AddToCabwiz(inf, profile, subDirectory);
            }

            foreach (var file in directoryInfo.Files)
            {
                this.AddToCabwiz(inf, profile, file);
            }
        }
Example #4
0
        /// <summary>
        /// Creates a <see cref="Cabwiz.InformationFile"/> for the project and the specified build profile.
        /// </summary>
        /// <param name="profile">The build profile to use when producing the output information.</param>
        /// <returns>A <see cref="Cabwiz.InformationFile"/> for the project and specified build profile.</returns>
        public Cabwiz.InformationFile CreateCabwizInf(BuildProfile profile)
        {
            var inf = new Cabwiz.InformationFile(this.ProjectInfo.ApplicationName, this.ProjectInfo.ProjectVersion);

            inf.FileName = string.Concat(this.ProjectInfo.GetOutputFileName(profile), Cabwiz.InformationFile.DefaultExtension);

            inf.Version.Provider = this.ProjectInfo.CompanyName;

            this.AddToCabwiz(inf, profile, this.InstallationDirectory);

            this.AddToCabwiz(inf, profile, this.ProjectInfo.GlobalRegistryKeys);

            return(inf);
        }
Example #5
0
        private void AddToCabwiz(Cabwiz.InformationFile inf, BuildProfile profile, RegistryKeyCollection registryKeys)
        {
            if (inf == null)
            {
                throw new ArgumentNullException("inf");
            }

            if (registryKeys != null)
            {
                foreach (var registryKey in registryKeys)
                {
                    this.AddToCabwiz(inf.AddReg, registryKey);
                }
            }
        }
Example #6
0
        /// <summary>
        /// Add a file to a information file, using the specified build profile.
        /// </summary>
        /// <param name="inf">The information file to add the directory to.</param>
        /// <param name="profile">The build profile used.</param>
        /// <param name="file">The file to add.</param>
        /// <remarks>
        ///     <para>
        ///         The file will not be added to the information file if
        ///             1. <paramref name="profile"/> is null, and <see cref="OutputFileInfo.SourceFile"/>
        ///                 is excluded by the project's global exclude list or it's current selected build profile.
        ///             2. or, <paramref name="profile"/> is not null and <see cref="OutputFileInfo.SourceFile"/>
        ///                 is excluded by <paramref name="profile"/>.
        ///     </para>
        /// </remarks>
        private void AddToCabwiz(Cabwiz.InformationFile inf, BuildProfile profile, OutputFileInfo file)
        {
            if (!this.ProjectInfo.IsExcluded(file.SourceFile, profile))
            {
                var sourceFile = file.SourceFile;

                if (file.IncludeRule != null)
                {
                    if (file.IncludeRule.XmlReplacementRules.Count > 0)
                    {
                        var tempFile = this.GetObjFileName(file, profile);

                        var rewriter = new XmlFileRewriter();

                        foreach (var replacement in file.IncludeRule.XmlReplacementRules)
                        {
                            rewriter.AddTextPath(replacement.Tag, this.ProjectInfo.ParseVariables(profile, replacement.Value));
                        }

                        rewriter.Rewrite(sourceFile, tempFile);

                        sourceFile = tempFile;
                    }
                    else if (!string.IsNullOrWhiteSpace(file.IncludeRule.FileName))
                    {
                        var tempFile = this.GetObjFileName(file, profile);

                        System.IO.File.Copy(file.SourceFile, tempFile, true);

                        sourceFile = tempFile;
                    }

                    if (!string.IsNullOrEmpty(file.IncludeRule.StartMenuShortcut))
                    {
                        inf.AddStartMenuShortcutToFile(
                            file.Name,
                            System.IO.Path.GetFileName(file.IncludeRule.StartMenuShortcut),
                            System.IO.Path.GetDirectoryName(file.IncludeRule.StartMenuShortcut));
                    }
                }

                inf.AddFile(sourceFile, file.Directory.FullName, file.Name);
            }
        }
Example #7
0
        private void WriteLine(System.IO.Stream s, Encoding encoding, string key, string value)
        {
            if (s == null)
            {
                throw new ArgumentNullException("s");
            }

            if (encoding == null)
            {
                throw new ArgumentNullException("encoding");
            }

            if (string.IsNullOrEmpty(key))
            {
                throw new ArgumentNullException("key");
            }

            var line = string.Format("{0}={1}", key, value);

            InformationFile.WriteLine(s, encoding, line);
        }
Example #8
0
        /// <summary>
        /// Executes and calls cabwiz.exe using the specified inf file.
        /// </summary>
        /// <param name="iniFile">A <see cref="InformationFile"/> to be written to the hard-drive.</param>
        /// <returns>The cabwiz.exe exit code. 0 indicates success, a non-zero value indicates failure.</returns>
        public int Run(InformationFile iniFile)
        {
            if (iniFile == null)
            {
                throw new ArgumentNullException("iniFile");
            }

            iniFile.WriteInformationFile();

            return this.Run(iniFile.FileName);
        }
Example #9
0
 /// <summary>
 /// Gets the command line, as it would be if <see cref="Run"/> was to be executed.
 /// </summary>
 /// <param name="informationFile">The information file to be used when creating the command line.</param>
 /// <returns>A command line <see cref="System.String"/>.</returns>
 public string PreviewCommandLine(InformationFile informationFile)
 {
     return this.PreviewCommandLine(informationFile.FileName);
 }
Example #10
0
        /// <summary>
        /// Quickly call cabwiz.exe.
        /// </summary>
        /// <param name="iniFile">The inf file object.</param>
        /// <param name="nouninstall">The <see cref="NoUninstall"/> property will be set to this value.</param>
        /// <param name="compress">The <see cref="Compress"/> property will be set to this value.</param>
        /// <returns>The cabwiz.exe exit code. 0 indicates success, a non-zero value indicates failure.</returns>
        public static int QuickRun(InformationFile iniFile, bool nouninstall, bool compress)
        {
            var app = new CabwizApplication();

            app.NoUninstall = nouninstall;
            app.Compress = compress;

            return app.Run(iniFile);
        }
Example #11
0
 protected virtual void WriteLine(System.IO.Stream s, Encoding encoding, string line)
 {
     InformationFile.WriteLine(s, encoding, line);
 }
Example #12
0
 /// <summary>
 /// Gets the command line, as it would be if <see cref="Run"/> was to be executed.
 /// </summary>
 /// <param name="informationFile">The information file to be used when creating the command line.</param>
 /// <returns>A command line <see cref="System.String"/>.</returns>
 public string PreviewCommandLine(InformationFile informationFile)
 {
     return(this.PreviewCommandLine(informationFile.FileName));
 }
Example #13
0
        /// <summary>
        /// Creates a <see cref="Cabwiz.InformationFile"/> for the project and the specified build profile.
        /// </summary>
        /// <param name="profile">The build profile to use when producing the output information.</param>
        /// <returns>A <see cref="Cabwiz.InformationFile"/> for the project and specified build profile.</returns>
        public Cabwiz.InformationFile CreateCabwizInf(BuildProfile profile)
        {
            var inf = new Cabwiz.InformationFile(this.ProjectInfo.ApplicationName, this.ProjectInfo.ProjectVersion);

            inf.FileName = string.Concat(this.ProjectInfo.GetOutputFileName(profile), Cabwiz.InformationFile.DefaultExtension);

            inf.Version.Provider = this.ProjectInfo.CompanyName;

            this.AddToCabwiz(inf, profile, this.InstallationDirectory);

            this.AddToCabwiz(inf, profile, this.ProjectInfo.GlobalRegistryKeys);

            return inf;
        }