Example #1
0
        /// <summary>
        /// Returns a dictionary of variable names and their values.
        /// </summary>
        /// <param name="profile">The profile for which to get the variables for.</param>
        /// <returns>A dictionary of variable names and their values.</returns>
        private Dictionary <string, string> GetVariableNames(BuildProfile profile)
        {
            var variables = new Dictionary <string, string>();

            variables.Add("Version", this.ProjectVersionString);
            variables.Add("ReleaseName", this.ReleaseName);
            variables.Add("Profile", profile != null ? profile.Name : null);
            variables.Add("ApplicationName", this.ApplicationName);
            variables.Add("CompanyName", this.CompanyName);

            foreach (var variable in variables.ToArray())
            {
                string value;
                if (string.IsNullOrEmpty(variable.Value))
                {
                    value = string.Empty;
                }
                else
                {
                    value = string.Concat("-", variable.Value);
                }

                variables.Add(string.Concat(variable.Key, "Part"), value);
            }

            return(variables);
        }
Example #2
0
        /// <summary>
        /// Parses <see cref="OutputFileName"/> and replaces all variable references with their respective values for the specified profile
        /// </summary>
        /// <param name="profile">The profile to be used when producing the filename.</param>
        /// <returns>A filename (without extension) that will be used by the build script.</returns>
        public string GetOutputFileName(BuildProfile profile)
        {
            string fileName = this.OutputFileName;

            if (!string.IsNullOrEmpty(fileName))
            {
                fileName = this.ParseVariables(profile, fileName);
            }
            else
            {
                fileName = System.IO.Path.GetFileNameWithoutExtension(this.ProjectFile.Name);
            }

            var buildPath = this.GetBuildDirectory(profile);

            if (!string.IsNullOrEmpty(buildPath))
            {
                fileName = System.IO.Path.Combine(buildPath, fileName);
            }

            if (!System.IO.Path.IsPathRooted(fileName))
            {
                fileName = System.IO.Path.Combine(this.ProjectFile.DirectoryName, fileName);
            }

            return(fileName);
        }
Example #3
0
        /// <summary>
        /// Prepares outout for a specified profile.
        /// </summary>
        /// <param name="profile">The profile for which the output should be generated.</param>
        /// <returns>A object which describes which files to include and where they should be stored in the final output.</returns>
        /// <remarks>
        ///     <para>
        ///         Currently, this method is merly a placeholder/workaround for future implementations as the architecture may change.
        ///     </para>
        /// </remarks>
        public ProjectOutput GetOutput(BuildProfile profile = null)
        {
            var output = this.Output;

            output.Refresh(profile);

            return(output);
        }
Example #4
0
        /// <summary>
        /// Initializes a new instance of the BuildProfileTask class with the specified profile.
        /// </summary>
        /// <param name="profile">The profile to build.</param>
        public BuildProfileTask(BuildProfile profile)
        {
            if (profile == null)
            {
                throw new ArgumentNullException("profile");
            }

            this.Profile = profile;
            this.Project = profile.ProjectInfo;
        }
Example #5
0
        /// <summary>
        /// Initializes a new instance of the BuildProfileTask class with the specified profile.
        /// </summary>
        /// <param name="profile">The profile to build.</param>
        public BuildProfileTask(BuildProfile profile)
        {
            if (profile == null)
            {
                throw new ArgumentNullException("profile");
            }

            this.Profile = profile;
            this.Project = profile.ProjectInfo;
        }
Example #6
0
        /// <summary>
        /// Returns a dictionary of variables with their names and respective values.
        /// </summary>
        /// <param name="profile">The profile for which to get the variables for.</param>
        /// <returns>A dictionary of variables and their values.</returns>
        private Dictionary <string, string> GetSysVariables(BuildProfile profile)
        {
            var variables = new Dictionary <string, string>();

            foreach (var name in this.GetVariableNames(profile))
            {
                this.AddVariable(variables, this.FormatVariableName(name.Key), name.Value);
            }

            return(variables);
        }
Example #7
0
        private Dictionary <string, string> GetVariables(BuildProfile profile)
        {
            var variables = this.GetSysVariables(profile);

            foreach (var userVariable in this.GetUserVariables(profile))
            {
                this.AddVariable(variables, this.FormatVariableName(userVariable.Key), this.ParseVariables(variables, userVariable.Value));
            }

            return(variables);
        }
Example #8
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 #9
0
        private Dictionary <string, string> GetUserVariables(BuildProfile profile)
        {
            var variables = new Dictionary <string, string>();

            this.AddUserVariables(variables, this.GlobalUserVariables);

            if (profile != null)
            {
                this.AddUserVariables(variables, profile.GetVariables());
            }

            return(variables);
        }
Example #10
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 #11
0
        /// <summary>
        /// Initializes a new instance of the BuildProfileTask class with the specified project and profile.
        /// </summary>
        /// <param name="project">The project to build.</param>
        /// <param name="profile">The profile to build.</param>
        public BuildProfileTask(ProjectInfo project, BuildProfile profile)
        {
            if (project == null)
            {
                throw new ArgumentNullException("project");
            }

            if (profile != null && project != profile.ProjectInfo)
            {
                throw new ArgumentException("The profile argument is not null and is not a profile child of the specified project", "profile");
            }

            this.Project = project;
            this.Profile = profile;
        }
Example #12
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 #13
0
 /// <summary>
 /// Determines whether <paramref name="profile"/> is located in this profile's family tree.
 /// </summary>
 /// <param name="profile">The profile to look for in the parent chain.</param>
 /// <returns>A value indicating whether <paramref name="profile"/> is located in this profile's family tree.</returns>
 public bool IsSubProfileOf(BuildProfile profile)
 {
     if (this == profile)
     {
         return(true);
     }
     else if (this.Parent != null)
     {
         return(this.Parent.IsSubProfileOf(profile));
     }
     else
     {
         return(false);
     }
 }
Example #14
0
        public string GetBuildDirectory(BuildProfile profile)
        {
            var directory = this.BuildPath;

            directory = this.ParseVariables(profile, directory);

            if (!System.IO.Path.IsPathRooted(directory))
            {
                return(System.IO.Path.Combine(this.ProjectFile.DirectoryName, directory));
            }
            else
            {
                return(directory);
            }
        }
Example #15
0
        /// <summary>
        /// Initializes a new instance of the BuildProfileTask class with the specified project and profile.
        /// </summary>
        /// <param name="project">The project to build.</param>
        /// <param name="profile">The profile to build.</param>
        public BuildProfileTask(ProjectInfo project, BuildProfile profile)
        {
            if (project == null)
            {
                throw new ArgumentNullException("project");
            }

            if (profile != null && project != profile.ProjectInfo)
            {
                throw new ArgumentException("The profile argument is not null and is not a profile child of the specified project", "profile");
            }

            this.Project = project;
            this.Profile = profile;
        }
Example #16
0
        /// <summary>
        /// Determines whether <paramref name="path"/> is excluded by the global settings or the current selected profile.
        /// </summary>
        /// <param name="path">The path to deterine wether it is excluded.</param>
        /// <returns>A value indicating whether <paramref name="path"/> is excluded globally or by the <see cref="CurrentProfile"/>.</returns>
        public bool IsExcluded(string path, BuildProfile profile = null)
        {
            if (string.IsNullOrEmpty(path))
            {
                return(false);
            }

            if (System.IO.Path.IsPathRooted(path) && this.IsExcludedExact(this.GetRelativePath(path), profile))
            {
                return(true);
            }
            else
            {
                return(this.IsExcludedExact(path, profile));
            }
        }
Example #17
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 #18
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);
        }
Example #19
0
        /// <summary>
        /// Returns a collection of include rules.
        /// </summary>
        /// <param name="profile">The profile to use to build the include rule collection. Set this parameter to null if the currently selected profile should be used instead.</param>
        /// <returns>A collection of include rules.</returns>
        public IncludeRuleCollection GetFiles(BuildProfile profile = null)
        {
            var l = new IncludeRuleCollection();

            if (this.GlobalIncludeRules != null)
            {
                l.AddRange(this.GlobalIncludeRules);
            }

            if (profile != null)
            {
                l.AddRange(profile.GetFiles());
            }
            else if (this.CurrentProfile != null)
            {
                l.AddRange(this.CurrentProfile.GetFiles());
            }

            return(l);
        }
Example #20
0
        /// <summary>
        /// Refreshes the output for the current project.
        /// </summary>
        public void Refresh(BuildProfile profile = null)
        {
            this.InstallationDirectory.Clear();
            this.ProgramFiles.Clear();
            this.StartMenu.Clear();

            var projectDirectory = this.ProjectInfo.ProjectFile.Directory;

            var rules = this.ProjectInfo.GetFiles(profile);

            foreach (var rule in rules)
            {
                var fullPath = System.IO.Path.Combine(projectDirectory.FullName, rule.Path);

                if (fullPath.Contains('*'))
                {
                    var dirName = System.IO.Path.GetDirectoryName(fullPath);

                    if (dirName.Contains('*'))
                    {
                        throw new InvalidOperationException("A wildcard was present in the path, but not on the filename portion.");
                    }
                    else if (System.IO.Directory.Exists(dirName))
                    {
                        var directory = new System.IO.DirectoryInfo(dirName);

                        var files = directory.GetFiles(System.IO.Path.GetFileName(fullPath));

                        foreach (var file in files)
                        {
                            this.AddFile(rule, file, rule.FileName);
                        }
                    }
                }
                else
                {
                    this.AddFile(rule, new System.IO.FileInfo(fullPath), rule.FileName);
                }
            }
        }
Example #21
0
 /// <summary>
 /// Determines whether <paramref name="path"/> is excluded by the global settings or the current selected profile.
 /// </summary>
 /// <param name="path">The path to deterine wether it is excluded.</param>
 /// <returns>A value indicating whether <paramref name="path"/> is excluded globally or by the <see cref="CurrentProfile"/>.</returns>
 public bool IsExcludedExact(string path, BuildProfile profile = null)
 {
     if (string.IsNullOrEmpty(path))
     {
         return(false);
     }
     else if (this.GlobalExcludeRules.IsExcluded(path))
     {
         return(true);
     }
     else if (profile != null)
     {
         return(profile.IsExcluded(path));
     }
     else if (this.CurrentProfile != null)
     {
         return(this.CurrentProfile.IsExcluded(path));
     }
     else
     {
         return(false);
     }
 }
Example #22
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;
        }
Example #23
0
 public string ParseVariables(BuildProfile profile, string value)
 {
     return(this.ParseVariables(this.GetVariables(profile), value));
 }
Example #24
0
        /// <summary>
        /// Returns a dictionary of variables with their names and respective values.
        /// </summary>
        /// <param name="profile">The profile for which to get the variables for.</param>
        /// <returns>A dictionary of variables and their values.</returns>
        private Dictionary<string, string> GetSysVariables(BuildProfile profile)
        {
            var variables = new Dictionary<string, string>();

            foreach (var name in this.GetVariableNames(profile))
            {
                this.AddVariable(variables, this.FormatVariableName(name.Key), name.Value);
            }

            return variables;
        }
Example #25
0
        /// <summary>
        /// Returns a collection of include rules.
        /// </summary>
        /// <param name="profile">The profile to use to build the include rule collection. Set this parameter to null if the currently selected profile should be used instead.</param>
        /// <returns>A collection of include rules.</returns>
        public IncludeRuleCollection GetFiles(BuildProfile profile = null)
        {
            var l = new IncludeRuleCollection();

            if (this.GlobalIncludeRules != null)
            {
                l.AddRange(this.GlobalIncludeRules);
            }

            if (profile != null)
            {
                l.AddRange(profile.GetFiles());
            }
            else if (this.CurrentProfile != null)
            {
                l.AddRange(this.CurrentProfile.GetFiles());
            }

            return l;
        }
Example #26
0
        /// <summary>
        /// Prepares outout for a specified profile.
        /// </summary>
        /// <param name="profile">The profile for which the output should be generated.</param>
        /// <returns>A object which describes which files to include and where they should be stored in the final output.</returns>
        /// <remarks>
        ///     <para>
        ///         Currently, this method is merly a placeholder/workaround for future implementations as the architecture may change.
        ///     </para>
        /// </remarks>
        public ProjectOutput GetOutput(BuildProfile profile = null)
        {
            var output = this.Output;

            output.Refresh(profile);

            return output;
        }
Example #27
0
        private Dictionary<string, string> GetUserVariables(BuildProfile profile)
        {
            var variables = new Dictionary<string, string>();

            this.AddUserVariables(variables, this.GlobalUserVariables);

            if (profile != null)
            {
                this.AddUserVariables(variables, profile.GetVariables());
            }

            return variables;
        }
Example #28
0
 /// <summary>
 /// Determines whether <paramref name="profile"/> is located in this profile's family tree.
 /// </summary>
 /// <param name="profile">The profile to look for in the parent chain.</param>
 /// <returns>A value indicating whether <paramref name="profile"/> is located in this profile's family tree.</returns>
 public bool IsSubProfileOf(BuildProfile profile)
 {
     if (this == profile)
     {
         return true;
     }
     else if (this.Parent != null)
     {
         return this.Parent.IsSubProfileOf(profile);
     }
     else
     {
         return false;
     }
 }
Example #29
0
        /// <summary>
        /// Returns a dictionary of variable names and their values.
        /// </summary>
        /// <param name="profile">The profile for which to get the variables for.</param>
        /// <returns>A dictionary of variable names and their values.</returns>
        private Dictionary<string, string> GetVariableNames(BuildProfile profile)
        {
            var variables = new Dictionary<string, string>();

            variables.Add("Version", this.ProjectVersionString);
            variables.Add("ReleaseName", this.ReleaseName);
            variables.Add("Profile", profile != null ? profile.Name : null);
            variables.Add("ApplicationName", this.ApplicationName);
            variables.Add("CompanyName", this.CompanyName);

            foreach (var variable in variables.ToArray())
            {
                string value;
                if (string.IsNullOrEmpty(variable.Value))
                {
                    value = string.Empty;
                }
                else
                {
                    value = string.Concat("-", variable.Value);
                }

                variables.Add(string.Concat(variable.Key, "Part"), value);
            }

            return variables;
        }
Example #30
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 #31
0
 public string ParseVariables(BuildProfile profile, string value)
 {
     return this.ParseVariables(this.GetVariables(profile), value);
 }
Example #32
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 #33
0
        private Dictionary<string, string> GetVariables(BuildProfile profile)
        {
            var variables = this.GetSysVariables(profile);

            foreach (var userVariable in this.GetUserVariables(profile))
            {
                this.AddVariable(variables, this.FormatVariableName(userVariable.Key), this.ParseVariables(variables, userVariable.Value));
            }

            return variables;
        }
Example #34
0
        /// <summary>
        /// Determines whether <paramref name="path"/> is excluded by the global settings or the current selected profile.
        /// </summary>
        /// <param name="path">The path to deterine wether it is excluded.</param>
        /// <returns>A value indicating whether <paramref name="path"/> is excluded globally or by the <see cref="CurrentProfile"/>.</returns>
        public bool IsExcluded(string path, BuildProfile profile = null)
        {
            if (string.IsNullOrEmpty(path))
            {
                return false;
            }

            if (System.IO.Path.IsPathRooted(path) && this.IsExcludedExact(this.GetRelativePath(path), profile))
            {
                return true;
            }
            else
            {
                return this.IsExcludedExact(path, profile);
            }
        }
Example #35
0
        /// <summary>
        /// Parses <see cref="OutputFileName"/> and replaces all variable references with their respective values for the specified profile
        /// </summary>
        /// <param name="profile">The profile to be used when producing the filename.</param>
        /// <returns>A filename (without extension) that will be used by the build script.</returns>
        public string GetOutputFileName(BuildProfile profile)
        {
            string fileName = this.OutputFileName;

            if (!string.IsNullOrEmpty(fileName))
            {
                fileName = this.ParseVariables(profile, fileName);
            }
            else
            {
                fileName = System.IO.Path.GetFileNameWithoutExtension(this.ProjectFile.Name);
            }

            var buildPath = this.GetBuildDirectory(profile);
            if (!string.IsNullOrEmpty(buildPath))
            {
                fileName = System.IO.Path.Combine(buildPath, fileName);
            }

            if (!System.IO.Path.IsPathRooted(fileName))
            {
                fileName = System.IO.Path.Combine(this.ProjectFile.DirectoryName, fileName);
            }

            return fileName;
        }
Example #36
0
        /// <summary>
        /// Refreshes the output for the current project.
        /// </summary>
        public void Refresh(BuildProfile profile = null)
        {
            this.InstallationDirectory.Clear();
            this.ProgramFiles.Clear();
            this.StartMenu.Clear();

            var projectDirectory = this.ProjectInfo.ProjectFile.Directory;

            var rules = this.ProjectInfo.GetFiles(profile);

            foreach (var rule in rules)
            {
                var fullPath = System.IO.Path.Combine(projectDirectory.FullName, rule.Path);

                if (fullPath.Contains('*'))
                {
                    var dirName = System.IO.Path.GetDirectoryName(fullPath);

                    if (dirName.Contains('*'))
                    {
                        throw new InvalidOperationException("A wildcard was present in the path, but not on the filename portion.");
                    }
                    else if (System.IO.Directory.Exists(dirName))
                    {
                        var directory = new System.IO.DirectoryInfo(dirName);

                        var files = directory.GetFiles(System.IO.Path.GetFileName(fullPath));

                        foreach (var file in files)
                        {
                            this.AddFile(rule, file, rule.FileName);
                        }
                    }
                }
                else
                {
                    this.AddFile(rule, new System.IO.FileInfo(fullPath), rule.FileName);
                }
            }
        }
Example #37
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 #38
0
        public string GetOutputDirectory(BuildProfile profile)
        {
            var directory = this.OutputPath;

            directory = this.ParseVariables(profile, directory);

            if (!System.IO.Path.IsPathRooted(directory))
            {
                return System.IO.Path.Combine(this.ProjectFile.DirectoryName, directory);
            }
            else
            {
                return directory;
            }
        }
Example #39
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 #40
0
 /// <summary>
 /// Determines whether <paramref name="path"/> is excluded by the global settings or the current selected profile.
 /// </summary>
 /// <param name="path">The path to deterine wether it is excluded.</param>
 /// <returns>A value indicating whether <paramref name="path"/> is excluded globally or by the <see cref="CurrentProfile"/>.</returns>
 public bool IsExcludedExact(string path, BuildProfile profile = null)
 {
     if (string.IsNullOrEmpty(path))
     {
         return false;
     }
     else if (this.GlobalExcludeRules.IsExcluded(path))
     {
         return true;
     }
     else if (profile != null)
     {
         return profile.IsExcluded(path);
     }
     else if (this.CurrentProfile != null)
     {
         return this.CurrentProfile.IsExcluded(path);
     }
     else
     {
         return false;
     }
 }