示例#1
0
        private void ExpandDirectory(string curDir, InstallerFile rootDir)
        {
            string baseDir = System.IO.Directory.GetCurrentDirectory();

            System.IO.Directory.SetCurrentDirectory(curDir);
            string[] files = System.IO.Directory.GetFiles(curDir);

            foreach (string file in files)
            {
                //Files must be absolute paths.
                if (!FileIsExcluded(file))
                {
                    string relPath;

                    relPath = file.Substring(rootDir.LocalPath.Length, file.Length - rootDir.LocalPath.Length);
                    relPath = StringUtils.CombinePath(rootDir.InstallerPath, relPath);
                    _lstFiles.Add(new InstallerFile(file, relPath));
                }
                else
                {
                    NumExcludedFiles++;
                }
            }

            string[] dirs = System.IO.Directory.GetDirectories(curDir);
            foreach (string dir in dirs)
            {
                if (!DirectoryIsExcluded(dir))
                {
                    ExpandDirectory(dir, rootDir);
                }
                else
                {
                    NumExcludedDirectories++;
                }
            }

            System.IO.Directory.SetCurrentDirectory(baseDir);
        }
示例#2
0
        private void ParseCommand(string line, int iLine)
        {
            line = line.Trim();
            if (string.IsNullOrEmpty(line))
            {
                return;
            }
            if (IsComment(line))
            {
                return;
            }

            string[] args = ParseLine(line);

            if (args.Length == 0)
            {
                return;
            }

            for (int i = 0; i < args.Length; i++)
            {
                args[i] = args[i].Trim();
            }

            List <string> lstInstallOptionKeys = new List <string> {
                InstallOption.DefaultDirectory,
                InstallOption.DisplayName,
                InstallOption.CreateDesktopShortcut,
                InstallOption.CreateStartMenuFolder,
                InstallOption.InstallLocation,
                InstallOption.Publisher,
                InstallOption.DisplayIcon,
                InstallOption.ApplicationVersion,
                InstallOption.DisplayVersion,
                InstallOption.URLInfoAbout,
                InstallOption.Contact,
                InstallOption.AppGuid,
            };


            if (args[0].Equals("BuildSection"))
            {
            }
            else if (args[0].Equals("InstallSection"))
            {
            }
            else if (args[0].Equals("Include"))
            {
                if (args.Length != 3)
                {
                    ThrowInvalidNumberOfParameters(args[0], iLine);
                }
                string local   = StringUtils.Dequote(args[1]);
                string install = StringUtils.Dequote(args[2]);

                InstallerFile newFile = new InstallerFile(local, install);

                if (IsDirectory(newFile.LocalPath))
                {
                    _lstIncludeDirs.Add(newFile);
                }
                else
                {
                    _lstIncludeFiles.Add(newFile);
                }
            }
            else if (args[0].Equals("Exclude"))
            {
                if (args.Length != 2)
                {
                    ThrowInvalidNumberOfParameters(args[0], iLine);
                }
                string local = StringUtils.Dequote(args[1]);

                InstallerFile newFile = new InstallerFile(local, "");

                if (IsDirectory(newFile.LocalPath))
                {
                    _lstExcludeDirs.Add(newFile);
                }
                else
                {
                    _lstExcludeFiles.Add(newFile);
                }
            }
            else if (args[0].Equals("ExcludeExt"))
            {
                if (args.Length != 2)
                {
                    ThrowInvalidNumberOfParameters(args[0], iLine);
                }
                string ext = StringUtils.Dequote(args[1]);
                ext = ext.ToLower();
                _lstExcludeExtensions.Add(ext);
            }
            //Option Directives
            else if (lstInstallOptionKeys.Contains(args[0]))
            {
                if (args.Length != 2)
                {
                    ThrowInvalidNumberOfParameters(args[0], iLine);
                }
                _objInstallOptions.Options.Add(new InstallOption(args[0], StringUtils.Dequote(args[1])));
            }
            else
            {
                Globals.Logger.LogWarn("Unrecognized installer config command " + args[0]);
            }
        }