Ejemplo n.º 1
0
        public OutputShortcutInfo AddShortcut(string shortcutFileName, OutputFileInfo target, IncludeRule rule)
        {
            var shortcutInfo = new OutputShortcutInfo(target, shortcutFileName, this);

            this.Shortcuts.Add(shortcutInfo);

            return(shortcutInfo);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Add a file to this directory.
        /// </summary>
        /// <param name="fileName">The name of the file as it will be on the target file system.</param>
        /// <param name="sourceFileName">The source file.</param>
        /// <returns>The <see cref="OutputFileInfo"/> object added.</returns>
        public OutputFileInfo AddFile(string fileName, string sourceFileName, IncludeRule rule)
        {
            var fileInfo = new OutputFileInfo(fileName, sourceFileName, this, rule);

            this.Files.Add(fileInfo);

            return(fileInfo);
        }
Ejemplo n.º 3
0
        private void AddShortcut(string shortcutFileName, OutputFileInfo outputFile, IncludeRule rule)
        {
            var path     = System.IO.Path.GetDirectoryName(shortcutFileName);
            var fileName = System.IO.Path.GetFileName(shortcutFileName);

            var dir = this.StartMenu;

            if (!string.IsNullOrEmpty(path))
            {
                dir = dir.AddSubDirectory(path);
            }

            dir.AddShortcut(fileName, outputFile, rule);
        }
Ejemplo n.º 4
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);
            }
        }
Ejemplo n.º 5
0
        private string GetObjFileName(OutputFileInfo file, BuildProfile profile)
        {
            var buildDirectory = this.ProjectInfo.GetBuildDirectory(profile);

            if (file.IncludeRule != null)
            {
                if (!string.IsNullOrWhiteSpace(file.IncludeRule.FileName))
                {
                    return(System.IO.Path.Combine(buildDirectory, file.IncludeRule.FileName));
                }
                else if (file.IncludeRule.XmlReplacementRules.Count > 0)
                {
                    return(System.IO.Path.Combine(buildDirectory, file.Name));
                }
            }

            // failover
            return(file.SourceFile);
        }
Ejemplo n.º 6
0
        public OutputShortcutInfo AddShortcut(string shortcutFileName, OutputFileInfo target, IncludeRule rule)
        {
            var shortcutInfo = new OutputShortcutInfo(target, shortcutFileName, this);

            this.Shortcuts.Add(shortcutInfo);

            return shortcutInfo;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Add a file to this directory.
        /// </summary>
        /// <param name="fileName">The name of the file as it will be on the target file system.</param>
        /// <param name="sourceFileName">The source file.</param>
        /// <returns>The <see cref="OutputFileInfo"/> object added.</returns>
        public OutputFileInfo AddFile(string fileName, string sourceFileName, IncludeRule rule)
        {
            var fileInfo = new OutputFileInfo(fileName, sourceFileName, this, rule);

            this.Files.Add(fileInfo);

            return fileInfo;
        }
Ejemplo n.º 8
0
        private string GetObjFileName(OutputFileInfo file, BuildProfile profile)
        {
            var buildDirectory = this.ProjectInfo.GetBuildDirectory(profile);

            if (file.IncludeRule != null)
            {
                if (!string.IsNullOrWhiteSpace(file.IncludeRule.FileName))
                {
                    return System.IO.Path.Combine(buildDirectory, file.IncludeRule.FileName);
                }
                else if (file.IncludeRule.XmlReplacementRules.Count > 0)
                {
                    return System.IO.Path.Combine(buildDirectory, file.Name);
                }
            }

            // failover
            return file.SourceFile;
        }
Ejemplo n.º 9
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);
            }
        }
Ejemplo n.º 10
0
        private void AddShortcut(string shortcutFileName, OutputFileInfo outputFile, IncludeRule rule)
        {
            var path = System.IO.Path.GetDirectoryName(shortcutFileName);
            var fileName = System.IO.Path.GetFileName(shortcutFileName);

            var dir = this.StartMenu;

            if (!string.IsNullOrEmpty(path))
            {
                dir = dir.AddSubDirectory(path);
            }

            dir.AddShortcut(fileName, outputFile, rule);
        }