コード例 #1
0
        /// <summary>
        /// Validates that a string is a valid directory name, and throws appropriate warnings/errors if not
        /// </summary>
        /// <param name="commandlineSwitch">The commandline switch we're parsing (for error display purposes).</param>
        /// <param name="messageHandler">The messagehandler to report warnings/errors to.</param>
        /// <param name="args">The list of strings to check.</param>
        /// <param name="index">The index (in args) of the commandline parameter to be parsed.</param>
        /// <param name="allowPrefix">Indicates if a colon-delimited prefix is allowed.</param>
        /// <returns>The string if it is valid, null if it is invalid.</returns>
        public static string GetDirectory(string commandlineSwitch, ConsoleMessageHandler messageHandler, string[] args, int index, bool allowPrefix)
        {
            commandlineSwitch = String.Concat("-", commandlineSwitch);

            if (!IsValidArg(args, index))
            {
                messageHandler.Display(null, WixErrors.DirectoryPathRequired(commandlineSwitch));
                return(null);
            }

            if (File.Exists(args[index]))
            {
                messageHandler.Display(null, WixErrors.ExpectedDirectoryGotFile(commandlineSwitch, args[index]));
                return(null);
            }

            return(VerifyPath(messageHandler, args[index], allowPrefix));
        }
コード例 #2
0
ファイル: CommandLine.cs プロジェクト: wixtoolset/codeplex
        /// <summary>
        /// Validates that a string is a valid directory name, and throws appropriate warnings/errors if not
        /// </summary>
        /// <param name="commandlineSwitch">The commandline switch we're parsing (for error display purposes).</param>
        /// <param name="args">The list of strings to check.</param>
        /// <param name="index">The index (in args) of the commandline parameter to be parsed.</param>
        /// <param name="allowPrefix">Indicates if a colon-delimited prefix is allowed.</param>
        /// <returns>The string if it is valid, null if it is invalid.</returns>
        public static string GetDirectory(string commandlineSwitch, string[] args, int index, bool allowPrefix = false)
        {
            commandlineSwitch = String.Concat("-", commandlineSwitch);

            if (!IsValidArg(args, index))
            {
                Messaging.Instance.OnMessage(WixErrors.DirectoryPathRequired(commandlineSwitch));
                return(null);
            }

            if (File.Exists(args[index]))
            {
                Messaging.Instance.OnMessage(WixErrors.ExpectedDirectoryGotFile(commandlineSwitch, args[index]));
                return(null);
            }

            return(VerifyPath(args[index], allowPrefix));
        }
コード例 #3
0
ファイル: CommandLine.cs プロジェクト: wixtoolset/codeplex
        /// <summary>
        /// Validates that a string is a valid bind path, and throws appropriate warnings/errors if not
        /// </summary>
        /// <param name="commandlineSwitch">The commandline switch we're parsing (for error display purposes).</param>
        /// <param name="args">The list of strings to check.</param>
        /// <param name="index">The index (in args) of the commandline parameter to be parsed.</param>
        /// <returns>The bind path if it is valid, null if it is invalid.</returns>
        public static BindPath GetBindPath(string commandlineSwitch, string[] args, int index)
        {
            commandlineSwitch = String.Concat("-", commandlineSwitch);

            if (!IsValidArg(args, index))
            {
                Messaging.Instance.OnMessage(WixErrors.DirectoryPathRequired(commandlineSwitch));
                return(null);
            }

            BindPath bindPath = BindPath.Parse(args[index]);

            if (File.Exists(bindPath.Path))
            {
                Messaging.Instance.OnMessage(WixErrors.ExpectedDirectoryGotFile(commandlineSwitch, bindPath.Path));
                return(null);
            }

            bindPath.Path = VerifyPath(bindPath.Path, true);
            return(String.IsNullOrEmpty(bindPath.Path) ? null : bindPath);
        }
コード例 #4
0
        /// <summary>
        /// Parse the commandline arguments.
        /// </summary>
        /// <param name="args">Commandline arguments.</param>
        private void ParseCommandLine(string[] args)
        {
            for (int i = 0; i < args.Length; ++i)
            {
                string arg = args[i];
                if (null == arg || 0 == arg.Length) // skip blank arguments
                {
                    continue;
                }

                if ('-' == arg[0] || '/' == arg[0])
                {
                    string parameter = arg.Substring(1);

                    if ("b" == parameter)
                    {
                        if (args.Length < ++i || '/' == args[i][0] || '-' == args[i][0])
                        {
                            this.messageHandler.Display(this, WixErrors.DirectoryPathRequired(String.Concat("-", parameter)));
                            return;
                        }

                        this.basePaths.Add(Path.GetFullPath(args[i]));
                    }
                    else if ("bf" == parameter)
                    {
                        this.bindFiles = true;
                    }
                    else if ("ext" == parameter)
                    {
                        if (args.Length < ++i || '/' == args[i][0] || '-' == args[i][0])
                        {
                            this.messageHandler.Display(this, WixErrors.TypeSpecificationForExtensionRequired("-ext"));
                            return;
                        }

                        this.extensionList.Add(args[i]);
                    }
                    else if ("loc" == parameter)
                    {
                        if (args.Length < ++i || '/' == args[i][0] || '-' == args[i][0])
                        {
                            this.messageHandler.Display(this, WixErrors.FilePathRequired(String.Concat("-", parameter)));
                            return;
                        }

                        this.localizationFiles.Add(Path.GetFullPath(args[i]));
                    }
                    else if ("nologo" == parameter)
                    {
                        this.showLogo = false;
                    }
                    else if ("o" == parameter || "out" == parameter)
                    {
                        if (args.Length < ++i || '/' == args[i][0] || '-' == args[i][0])
                        {
                            this.messageHandler.Display(this, WixErrors.FilePathRequired(String.Concat("-", parameter)));
                            return;
                        }

                        this.outputFile = Path.GetFullPath(args[i]);
                    }
                    else if ("ss" == parameter)
                    {
                        this.suppressSchema = true;
                    }
                    else if ("sv" == parameter)
                    {
                        this.suppressVersionCheck = true;
                    }
                    else if (parameter.StartsWith("sw"))
                    {
                        try
                        {
                            int suppressWarning = Convert.ToInt32(parameter.Substring(2), CultureInfo.InvariantCulture.NumberFormat);

                            if (0 >= suppressWarning)
                            {
                                this.messageHandler.Display(this, WixErrors.IllegalSuppressWarningId(parameter.Substring(2)));
                            }

                            this.messageHandler.SuppressWarningMessage(suppressWarning);
                        }
                        catch (FormatException)
                        {
                            this.messageHandler.Display(this, WixErrors.IllegalSuppressWarningId(parameter.Substring(2)));
                        }
                        catch (OverflowException)
                        {
                            this.messageHandler.Display(this, WixErrors.IllegalSuppressWarningId(parameter.Substring(2)));
                        }
                    }
                    else if ("v" == parameter)
                    {
                        this.messageHandler.ShowVerboseMessages = true;
                    }
                    else if ("wx" == parameter)
                    {
                        this.messageHandler.WarningAsError = true;
                    }
                    else if ("?" == parameter || "help" == parameter)
                    {
                        this.showHelp = true;
                    }
                }
                else if ('@' == arg[0])
                {
                    this.ParseCommandLine(AppCommon.ParseResponseFile(arg.Substring(1)));
                }
                else
                {
                    this.inputFiles.AddRange(AppCommon.GetFiles(arg, "Source"));
                }
            }
        }
コード例 #5
0
        /// <summary>
        /// Parse the commandline arguments.
        /// </summary>
        /// <param name="args">Commandline arguments.</param>
        private void ParseCommandLine(string[] args)
        {
            for (int i = 0; i < args.Length; ++i)
            {
                string arg = args[i];
                if (null == arg || 0 == arg.Length)                 // skip blank arguments
                {
                    continue;
                }

                if ('-' == arg[0] || '/' == arg[0])
                {
                    string parameter = arg.Substring(1);
                    if ("o" == parameter || "out" == parameter)
                    {
                        if (args.Length < ++i || '/' == args[i][0] || '-' == args[i][0])
                        {
                            this.OnMessage(WixErrors.FilePathRequired(String.Concat("-", parameter)));
                            return;
                        }

                        this.outputFile = new FileInfo(args[i]);
                    }
                    else if ("ai" == parameter)
                    {
                        this.allowIdenticalRows = true;
                    }
                    else if ("au" == parameter)
                    {
                        this.allowUnresolvedReferences = true;
                    }
                    else if ("b" == parameter)
                    {
                        if (args.Length < ++i || '/' == args[i][0] || '-' == args[i][0])
                        {
                            this.OnMessage(WixErrors.DirectoryPathRequired(String.Concat("-", parameter)));
                            return;
                        }

                        this.basePaths.Add(args[i]);
                    }
                    else if ("cc" == parameter)
                    {
                        if (args.Length < ++i || '/' == args[i][0] || '-' == args[i][0])
                        {
                            this.OnMessage(WixErrors.DirectoryPathRequired(String.Concat("-", parameter)));
                            return;
                        }

                        this.cabCachePath = args[i];
                    }
                    else if ("ext" == parameter)
                    {
                        if (args.Length < ++i || '/' == args[i][0] || '-' == args[i][0])
                        {
                            this.OnMessage(WixErrors.TypeSpecificationForExtensionRequired("-ext"));
                            return;
                        }

                        this.extensionList.Add(args[i]);
                    }
                    else if ("fv" == parameter)
                    {
                        this.setMsiAssemblyNameFileVersion = true;
                    }
                    else if ("i" == parameter)
                    {
                        ++i;
                        if (!((args[i]).EndsWith("\\")))
                        {
                            this.imagebaseOutputPath = args[i] + "\\";
                        }
                        else
                        {
                            this.imagebaseOutputPath = args[i];
                        }
                    }
                    else if ("nologo" == parameter)
                    {
                        this.showLogo = false;
                    }
                    else if ("notidy" == parameter)
                    {
                        this.tidy = false;
                    }
                    else if ("loc" == parameter)
                    {
                        if (args.Length < ++i || '/' == args[i][0] || '-' == args[i][0])
                        {
                            this.OnMessage(WixErrors.FilePathRequired(String.Concat("-", parameter)));
                            return;
                        }

                        this.localizationFiles.Add(args[i]);
                    }
                    else if ("xo" == parameter)
                    {
                        this.outputXml = true;
                    }
                    else if (parameter.StartsWith("pedantic"))
                    {
                        if ("pedantic:easy" == parameter)
                        {
                            this.pedanticLevel = PedanticLevel.Easy;
                        }
                        else if ("pedantic:heroic" == parameter)
                        {
                            this.pedanticLevel = PedanticLevel.Heroic;
                        }
                        else if ("pedantic:legendary" == parameter)
                        {
                            this.pedanticLevel = PedanticLevel.Legendary;
                        }
                        else                         // default is heroic
                        {
                            this.pedanticLevel = PedanticLevel.Heroic;
                        }
                    }
                    else if ("reusecab" == parameter)
                    {
                        this.reuseCabinets = true;
                    }
                    else if ("sa" == parameter)
                    {
                        this.suppressAssemblies = true;
                    }
                    else if ("sacl" == parameter)
                    {
                        this.suppressAclReset = true;
                    }
                    else if ("sadmin" == parameter)
                    {
                        this.suppressAdminSequence = true;
                    }
                    else if ("sadv" == parameter)
                    {
                        this.suppressAdvertiseSequence = true;
                    }
                    else if ("sf" == parameter)
                    {
                        this.suppressFiles = true;
                    }
                    else if ("sh" == parameter)
                    {
                        this.suppressFileHashAndInfo = true;
                    }
                    else if ("sl" == parameter)
                    {
                        this.suppressLayout = true;
                    }
                    else if ("ss" == parameter)
                    {
                        this.suppressSchema = true;
                    }
                    else if ("sui" == parameter)
                    {
                        this.suppressUISequence = true;
                    }
                    else if ("sv" == parameter)
                    {
                        this.suppressVersionCheck = true;
                    }
                    else if ("sw" == parameter)
                    {
                        this.messageHandler.MinimumWarningLevel = WarningLevel.Deprecated;
                    }
                    else if ('s' == parameter[0] && 'w' == parameter[1])
                    {
                        try
                        {
                            int suppressWarning = Convert.ToInt32(parameter.Substring(2), CultureInfo.InvariantCulture.NumberFormat);

                            if (0 >= suppressWarning)
                            {
                                this.OnMessage(WixErrors.IllegalSuppressWarningId(parameter.Substring(2)));
                            }

                            this.messageHandler.SuppressWarningMessage(suppressWarning);
                        }
                        catch (FormatException)
                        {
                            this.OnMessage(WixErrors.IllegalSuppressWarningId(parameter.Substring(2)));
                        }
                        catch (OverflowException)
                        {
                            this.OnMessage(WixErrors.IllegalSuppressWarningId(parameter.Substring(2)));
                        }
                    }
                    else if ("ts" == parameter)
                    {
                        this.sectionIdOnTuples = true;
                    }
                    else if ("ust" == parameter)
                    {
                        this.useSmallTables = true;
                    }
                    else if ('v' == parameter[0])
                    {
                        if (parameter.Length > 1)
                        {
                            parameter = arg.Substring(2);

                            try
                            {
                                int userVerbosityLevel = Convert.ToInt32(parameter, CultureInfo.InvariantCulture.NumberFormat);

                                if (0 > userVerbosityLevel || 3 < userVerbosityLevel)
                                {
                                    this.OnMessage(WixErrors.IllegalVerbosityLevel(parameter));
                                    continue;
                                }

                                this.messageHandler.MaximumVerbosityLevel = (VerboseLevel)userVerbosityLevel;
                            }
                            catch (FormatException)
                            {
                                this.OnMessage(WixErrors.IllegalVerbosityLevel(parameter));
                            }
                            catch (OverflowException)
                            {
                                this.OnMessage(WixErrors.IllegalVerbosityLevel(parameter));
                            }
                        }
                        else                         // verbosity level not specified; use default
                        {
                            this.messageHandler.MaximumVerbosityLevel = VerboseLevel.Verbose;
                        }
                    }
                    else if ('w' == parameter[0])
                    {
                        parameter = arg.Substring(2);

                        if ("x" == parameter)
                        {
                            this.messageHandler.WarningAsError = true;
                        }
                        else
                        {
                            try
                            {
                                int userWarningLevel = Convert.ToInt32(parameter, CultureInfo.InvariantCulture.NumberFormat);

                                if (0 > userWarningLevel || 3 < userWarningLevel)
                                {
                                    this.OnMessage(WixErrors.IllegalWarningLevel(parameter));
                                    continue;
                                }

                                this.messageHandler.MinimumWarningLevel = (WarningLevel)userWarningLevel;
                            }
                            catch (FormatException)
                            {
                                this.OnMessage(WixErrors.IllegalWarningLevel(parameter));
                            }
                            catch (OverflowException)
                            {
                                this.OnMessage(WixErrors.IllegalWarningLevel(parameter));
                            }
                        }
                    }
                    else if ("?" == parameter || "help" == parameter)
                    {
                        this.showHelp = true;
                    }
                }
                else if ('@' == arg[0])
                {
                    this.ParseCommandLine(Common.ParseResponseFile(arg.Substring(1)));
                }
                else
                {
                    this.objectFiles.AddRange(Common.GetFiles(arg, "Source"));
                }
            }
        }
コード例 #6
0
ファイル: dark.cs プロジェクト: sillsdev/FwSupportTools
        /// <summary>
        /// Parse the commandline arguments.
        /// </summary>
        /// <param name="args">Commandline arguments.</param>
        private void ParseCommandLine(string[] args)
        {
            for (int i = 0; i < args.Length; ++i)
            {
                string arg = args[i];
                if (null == arg || 0 == arg.Length)                 // skip blank arguments
                {
                    continue;
                }

                if ('-' == arg[0] || '/' == arg[0])
                {
                    string parameter = arg.Substring(1);
                    if ("o" == parameter || "out" == parameter)
                    {
                        if (args.Length < ++i || '/' == args[i][0] || '-' == args[i][0])
                        {
                            this.OnMessage(WixErrors.FilePathRequired(String.Concat("-", parameter)));
                            return;
                        }

                        this.outputFile = args[i];
                    }
                    else if ("vsi" == parameter)
                    {
                        this.skipVSI = true;
                    }
                    else if ("is" == parameter)
                    {
                        this.skipInstallShield = true;
                    }
                    else if ("n" == parameter)
                    {
                        this.skipUI = true;
                    }
                    else if ("ui" == parameter)
                    {
                        this.processUIOnly = true;
                    }
                    else if ("s" == parameter)
                    {
                        this.skipSequenceTables = true;
                    }
                    else if ("z" == parameter)
                    {
                        this.explicitSequenceTables = true;
                    }
                    else if ("p" == parameter)
                    {
                        this.skipSummaryInfo = true;
                    }
                    else if ("x" == parameter)
                    {
                        this.exportBinaries = true;
                        if (args.Length < ++i || '/' == args[i][0] || '-' == args[i][0])
                        {
                            this.OnMessage(WixErrors.DirectoryPathRequired(String.Concat("-", parameter)));
                            return;
                        }

                        this.basePath = args[i];
                    }
                    else if ("m" == parameter)
                    {
                        this.processingModule = true;
                    }
                    else if ("f" == parameter)
                    {
                        this.generateFragments = true;
                    }
                    else if ("e" == parameter)
                    {
                        this.keepEmptyTables = true;
                    }
                    else if ("ext" == parameter)
                    {
                        if (args.Length < ++i || '/' == args[i][0] || '-' == args[i][0])
                        {
                            this.OnMessage(WixErrors.TypeSpecificationForExtensionRequired("-ext"));
                            return;
                        }

                        this.extensionList.Add(args[i]);
                    }
                    else if ("g" == parameter)
                    {
                        this.processingFragment = true;
                    }
                    else if ("c" == parameter)
                    {
                        this.addComments = true;
                    }
                    else if ("sw" == parameter)
                    {
                        this.messageHandler.MinimumWarningLevel = WarningLevel.Deprecated;
                    }
                    else if ('s' == parameter[0] && 'w' == parameter[1])
                    {
                        try
                        {
                            int suppressWarning = Convert.ToInt32(parameter.Substring(2), CultureInfo.InvariantCulture.NumberFormat);

                            if (0 >= suppressWarning)
                            {
                                this.OnMessage(WixErrors.IllegalSuppressWarningId(parameter.Substring(2)));
                            }

                            this.messageHandler.SuppressWarningMessage(suppressWarning);
                        }
                        catch (FormatException)
                        {
                            this.OnMessage(WixErrors.IllegalSuppressWarningId(parameter.Substring(2)));
                        }
                        catch (OverflowException)
                        {
                            this.OnMessage(WixErrors.IllegalSuppressWarningId(parameter.Substring(2)));
                        }
                    }
                    else if ('v' == parameter[0])
                    {
                        if (parameter.Length > 1)
                        {
                            parameter = arg.Substring(2);

                            try
                            {
                                int userVerbosityLevel = Convert.ToInt32(parameter, CultureInfo.InvariantCulture.NumberFormat);

                                if (0 > userVerbosityLevel || 3 < userVerbosityLevel)
                                {
                                    this.OnMessage(WixErrors.IllegalVerbosityLevel(parameter));
                                    continue;
                                }

                                this.messageHandler.MaximumVerbosityLevel = (VerboseLevel)userVerbosityLevel;
                            }
                            catch (FormatException)
                            {
                                this.OnMessage(WixErrors.IllegalVerbosityLevel(parameter));
                            }
                            catch (OverflowException)
                            {
                                this.OnMessage(WixErrors.IllegalVerbosityLevel(parameter));
                            }
                        }
                        else                         // verbosity level not specified; use default
                        {
                            this.messageHandler.MaximumVerbosityLevel = VerboseLevel.Verbose;
                        }
                    }
                    else if ('w' == parameter[0])
                    {
                        parameter = arg.Substring(2);

                        if ("x" == parameter)
                        {
                            this.messageHandler.WarningAsError = true;
                        }
                        else
                        {
                            try
                            {
                                int userWarningLevel = Convert.ToInt32(parameter, CultureInfo.InvariantCulture.NumberFormat);

                                if (0 > userWarningLevel || 3 < userWarningLevel)
                                {
                                    this.OnMessage(WixErrors.IllegalWarningLevel(parameter));
                                    continue;
                                }

                                this.messageHandler.MinimumWarningLevel = (WarningLevel)userWarningLevel;
                            }
                            catch (FormatException)
                            {
                                this.OnMessage(WixErrors.IllegalWarningLevel(parameter));
                            }
                            catch (OverflowException)
                            {
                                this.OnMessage(WixErrors.IllegalWarningLevel(parameter));
                            }
                        }
                    }
                    else if ("?" == parameter || "help" == parameter)
                    {
                        this.showHelp = true;
                    }
                    else if ("nologo" == parameter)
                    {
                        this.showLogo = false;
                    }
                    else if ("notidy" == parameter)
                    {
                        this.tidy = false;
                    }
                }
                else
                {
                    if (null == this.inputFile || 0 == this.inputFile.Length)
                    {
                        this.inputFile = arg;
                    }
                    else if (null == this.outputFile || 0 == this.outputFile.Length)
                    {
                        this.outputFile = arg;
                    }
                    else
                    {
                        this.OnMessage(WixErrors.AdditionalArgumentUnexpected(arg));
                    }
                }
            }
        }
コード例 #7
0
        /// <summary>
        /// Parse the commandline arguments.
        /// </summary>
        /// <param name="args">Commandline arguments.</param>
        private void ParseCommandLine(string[] args)
        {
            for (int i = 0; i < args.Length; ++i)
            {
                string arg = args[i];
                if (null == arg || 0 == arg.Length) // skip blank arguments
                {
                    continue;
                }

                if ('-' == arg[0] || '/' == arg[0])
                {
                    string parameter = arg.Substring(1);

                    if ("cc" == parameter)
                    {
                        if (args.Length < ++i || '/' == args[i][0] || '-' == args[i][0])
                        {
                            this.messageHandler.Display(this, WixErrors.DirectoryPathRequired(String.Concat("-", parameter)));
                            return;
                        }

                        this.cabCachePath = args[i];
                    }
                    else if ("ext" == parameter)
                    {
                        if (null != this.extension)
                        {
                            this.messageHandler.Display(this, WixErrors.SingleExtensionSupported());
                            return;
                        }

                        if (args.Length < ++i || '/' == args[i][0] || '-' == args[i][0])
                        {
                            this.messageHandler.Display(this, WixErrors.TypeSpecificationForExtensionRequired("-ext"));
                            return;
                        }

                        this.extension = args[i];
                    }
                    else if ("nologo" == parameter)
                    {
                        this.showLogo = false;
                    }
                    else if ("notidy" == parameter)
                    {
                        this.tidy = false;
                    }
                    else if (parameter.StartsWith("sw"))
                    {
                        try
                        {
                            int suppressWarning = Convert.ToInt32(parameter.Substring(2), CultureInfo.InvariantCulture.NumberFormat);

                            if (0 >= suppressWarning)
                            {
                                this.OnMessage(WixErrors.IllegalSuppressWarningId(parameter.Substring(2)));
                            }

                            this.messageHandler.SuppressWarningMessage(suppressWarning);
                        }
                        catch (FormatException)
                        {
                            this.OnMessage(WixErrors.IllegalSuppressWarningId(parameter.Substring(2)));
                        }
                        catch (OverflowException)
                        {
                            this.OnMessage(WixErrors.IllegalSuppressWarningId(parameter.Substring(2)));
                        }
                    }
                    if ("o" == parameter || "out" == parameter)
                    {
                        if (args.Length < ++i || '/' == args[i][0] || '-' == args[i][0])
                        {
                            this.messageHandler.Display(this, WixErrors.FilePathRequired(String.Concat("-", parameter)));
                            return;
                        }

                        this.outputFile = Path.GetFullPath(args[i]);
                    }
                    else if ("reusecab" == parameter)
                    {
                        this.reuseCabinets = true;
                    }
                    else if ("sa" == parameter)
                    {
                        this.suppressAssemblies = true;
                    }
                    else if ("sf" == parameter)
                    {
                        this.suppressFiles = true;
                    }
                    else if ("sh" == parameter)
                    {
                        this.suppressFileHashAndInfo = true;
                    }
                    else if ("t" == parameter)
                    {
                        string transform = null;
                        string baseline  = null;

                        if (args.Length < ++i || '/' == args[i][0] || '-' == args[i][0])
                        {
                            this.messageHandler.Display(this, WixErrors.BaselineRequired());
                            return;
                        }

                        baseline = args[i];

                        if (args.Length < ++i || '/' == args[i][0] || '-' == args[i][0])
                        {
                            this.messageHandler.Display(this, WixErrors.FilePathRequired(String.Concat("-", parameter)));
                            return;
                        }

                        transform = Path.GetFullPath(args[i]).ToLower();

                        // Verify the transform hasnt already been added.
                        if (this.inputTransforms.ContainsKey(transform))
                        {
                            this.messageHandler.Display(this, WixErrors.DuplicateTransform(transform));
                            return;
                        }

                        this.inputTransforms.Add(transform, baseline);
                    }
                    else if ("v" == parameter)
                    {
                        this.messageHandler.ShowVerboseMessages = true;
                    }
                    else if ("wx" == parameter)
                    {
                        this.messageHandler.WarningAsError = true;
                    }
                    else if ("?" == parameter || "help" == parameter)
                    {
                        this.showHelp = true;
                    }
                }
                else if ('@' == arg[0])
                {
                    this.ParseCommandLine(AppCommon.ParseResponseFile(arg.Substring(1)));
                }
                else
                {
                    if (null == this.inputFile)
                    {
                        this.inputFile = Path.GetFullPath(args[i]);
                    }
                    else
                    {
                        this.OnMessage(WixErrors.AdditionalArgumentUnexpected(arg));
                    }
                }
            }
        }
コード例 #8
0
        /// <summary>
        /// Parse the commandline arguments.
        /// </summary>
        /// <param name="args">Commandline arguments.</param>
        private void ParseCommandLine(string[] args)
        {
            for (int i = 0; i < args.Length; ++i)
            {
                string arg = args[i];
                if (null == arg || 0 == arg.Length) // skip blank arguments
                {
                    continue;
                }

                if ('-' == arg[0] || '/' == arg[0])
                {
                    string parameter = arg.Substring(1);

                    if ("ext" == parameter)
                    {
                        if (args.Length < ++i || '/' == args[i][0] || '-' == args[i][0])
                        {
                            this.messageHandler.Display(this, WixErrors.TypeSpecificationForExtensionRequired("-ext"));
                            return;
                        }

                        this.extensionList.Add(args[i]);
                    }
                    else if ("nologo" == parameter)
                    {
                        this.showLogo = false;
                    }
                    else if ("notidy" == parameter)
                    {
                        this.tidy = false;
                    }
                    else if ("sdet" == parameter)
                    {
                        this.suppressDroppingEmptyTables = true;
                    }
                    else if ("sras" == parameter)
                    {
                        this.suppressRelativeActionSequencing = true;
                    }
                    else if ("sui" == parameter)
                    {
                        this.suppressUI = true;
                    }
                    else if (parameter.StartsWith("sw"))
                    {
                        try
                        {
                            int suppressWarning = Convert.ToInt32(parameter.Substring(2), CultureInfo.InvariantCulture.NumberFormat);

                            if (0 >= suppressWarning)
                            {
                                this.messageHandler.Display(this, WixErrors.IllegalSuppressWarningId(parameter.Substring(2)));
                            }

                            this.messageHandler.SuppressWarningMessage(suppressWarning);
                        }
                        catch (FormatException)
                        {
                            this.messageHandler.Display(this, WixErrors.IllegalSuppressWarningId(parameter.Substring(2)));
                        }
                        catch (OverflowException)
                        {
                            this.messageHandler.Display(this, WixErrors.IllegalSuppressWarningId(parameter.Substring(2)));
                        }
                    }
                    else if ("v" == parameter)
                    {
                        this.messageHandler.ShowVerboseMessages = true;
                    }
                    else if ("wx" == parameter)
                    {
                        this.messageHandler.WarningAsError = true;
                    }
                    else if ("x" == parameter)
                    {
                        if (args.Length < ++i || '/' == args[i][0] || '-' == args[i][0])
                        {
                            this.messageHandler.Display(this, WixErrors.DirectoryPathRequired(String.Concat("-", parameter)));
                            return;
                        }

                        this.exportBasePath = Path.GetFullPath(args[i]);
                    }
                    else if ("xo" == parameter)
                    {
                        this.outputXml = true;
                    }
                    else if ("?" == parameter || "help" == parameter)
                    {
                        this.showHelp = true;
                    }
                }
                else
                {
                    if (null == this.inputFile)
                    {
                        this.inputFile = Path.GetFullPath(arg);

                        // guess the output type based on the extension of the input file
                        if (OutputType.Unknown == this.outputType)
                        {
                            switch (Path.GetExtension(this.inputFile).ToLower(CultureInfo.InvariantCulture))
                            {
                            case ".msi":
                                this.outputType = OutputType.Product;
                                break;

                            case ".msm":
                                this.outputType = OutputType.Module;
                                break;

                            case ".msp":
                                this.outputType = OutputType.Patch;
                                break;

                            case ".mst":
                                this.outputType = OutputType.Transform;
                                break;

                            case ".pcp":
                                this.outputType = OutputType.PatchCreation;
                                break;

                            default:
                                throw new ArgumentException(String.Format("Cannot determine the type of msi database file based on file extension '{0}'.", Path.GetExtension(this.inputFile)));
                            }
                        }
                    }
                    else if (null == this.outputFile)
                    {
                        this.outputFile = Path.GetFullPath(arg);
                    }
                    else
                    {
                        this.messageHandler.Display(this, WixErrors.AdditionalArgumentUnexpected(arg));
                    }
                }
            }
        }
コード例 #9
0
        /// <summary>
        /// Parse the commandline arguments.
        /// </summary>
        /// <param name="args">Commandline arguments.</param>
        private void ParseCommandLine(string[] args)
        {
            for (int i = 0; i < args.Length; ++i)
            {
                string arg = args[i];
                if (null == arg || 0 == arg.Length) // skip blank arguments
                {
                    continue;
                }

                if ('-' == arg[0] || '/' == arg[0])
                {
                    string parameter = arg.Substring(1);
                    if ("o" == parameter || "out" == parameter)
                    {
                        if (args.Length < ++i || '/' == args[i][0] || '-' == args[i][0])
                        {
                            this.messageHandler.Display(this, WixErrors.FilePathRequired(String.Concat("-", parameter)));
                            return;
                        }

                        this.outputFile = Path.GetFullPath(args[i]);
                    }
                    else if ("ai" == parameter)
                    {
                        this.allowIdenticalRows = true;
                    }
                    else if ("au" == parameter)
                    {
                        this.allowUnresolvedReferences = true;
                    }
                    else if ("b" == parameter)
                    {
                        if (args.Length < ++i || '/' == args[i][0] || '-' == args[i][0])
                        {
                            this.messageHandler.Display(this, WixErrors.DirectoryPathRequired(String.Concat("-", parameter)));
                            return;
                        }

                        this.basePaths.Add(Path.GetFullPath(args[i]));
                    }
                    else if ("bf" == parameter)
                    {
                        this.bindFiles = true;
                    }
                    else if ("cc" == parameter)
                    {
                        if (args.Length < ++i || '/' == args[i][0] || '-' == args[i][0])
                        {
                            this.messageHandler.Display(this, WixErrors.DirectoryPathRequired(String.Concat("-", parameter)));
                            return;
                        }

                        this.cabCachePath = args[i];
                    }
                    else if ("ct" == parameter)
                    {
                        if (args.Length < ++i || '/' == args[i][0] || '-' == args[i][0])
                        {
                            this.messageHandler.Display(this, WixErrors.IllegalCabbingThreadCount(String.Empty));
                            return;
                        }
                        try
                        {
                            this.cabbingThreadCount = Convert.ToInt32(args[i], CultureInfo.InvariantCulture.NumberFormat);

                            if (0 >= this.cabbingThreadCount)
                            {
                                this.messageHandler.Display(this, WixErrors.IllegalCabbingThreadCount(args[i]));
                            }
                        }
                        catch (FormatException)
                        {
                            this.messageHandler.Display(this, WixErrors.IllegalCabbingThreadCount(args[i]));
                        }
                        catch (OverflowException)
                        {
                            this.messageHandler.Display(this, WixErrors.IllegalCabbingThreadCount(args[i]));
                        }
                    }
                    else if (parameter.StartsWith("cultures:"))
                    {
                        this.cultures = arg.Substring(10).ToLower(CultureInfo.InvariantCulture).Split(';');
                    }
                    else if (parameter.StartsWith("cub"))
                    {
                        if (args.Length < ++i || '/' == args[i][0] || '-' == args[i][0])
                        {
                            this.messageHandler.Display(this, WixErrors.FilePathRequired("-cub"));
                            return;
                        }

                        this.validator.AddCubeFile(args[i]);
                    }
                    else if (parameter.StartsWith("d"))
                    {
                        parameter = arg.Substring(2);
                        string[] value = parameter.Split("=".ToCharArray(), 2);

                        if (1 == value.Length)
                        {
                            this.messageHandler.Display(this, WixErrors.ExpectedWixVariableValue(value[0]));
                        }
                        else
                        {
                            this.wixVariableResolver.AddVariable(value[0], value[1]);
                        }
                    }
                    else if ("ext" == parameter)
                    {
                        if (args.Length < ++i || '/' == args[i][0] || '-' == args[i][0])
                        {
                            this.messageHandler.Display(this, WixErrors.TypeSpecificationForExtensionRequired("-ext"));
                            return;
                        }

                        this.extensionList.Add(args[i]);
                    }
                    else if ("fv" == parameter)
                    {
                        this.setMsiAssemblyNameFileVersion = true;
                    }
                    else if ("loc" == parameter)
                    {
                        if (args.Length < ++i || '/' == args[i][0] || '-' == args[i][0])
                        {
                            this.messageHandler.Display(this, WixErrors.FilePathRequired(String.Concat("-", parameter)));
                            return;
                        }

                        this.localizationFiles.Add(Path.GetFullPath(args[i]));
                    }
                    else if ("nologo" == parameter)
                    {
                        this.showLogo = false;
                    }
                    else if ("notidy" == parameter)
                    {
                        this.tidy = false;
                    }
                    else if ("usf" == parameter)
                    {
                        if (args.Length < ++i || '/' == args[i][0] || '-' == args[i][0])
                        {
                            this.messageHandler.Display(this, WixErrors.FilePathRequired(String.Concat("-", parameter)));
                            return;
                        }

                        this.unreferencedSymbolsFile = Path.GetFullPath(args[i]);
                    }
                    else if ("pedantic" == parameter)
                    {
                        this.showPedanticMessages = true;
                    }
                    else if ("reusecab" == parameter)
                    {
                        this.reuseCabinets = true;
                    }
                    else if ("sa" == parameter)
                    {
                        this.suppressAssemblies = true;
                    }
                    else if ("sacl" == parameter)
                    {
                        this.suppressAclReset = true;
                    }
                    else if ("sadmin" == parameter)
                    {
                        this.suppressAdminSequence = true;
                    }
                    else if ("sadv" == parameter)
                    {
                        this.suppressAdvertiseSequence = true;
                    }
                    else if ("sdut" == parameter)
                    {
                        this.suppressDroppingUnrealTables = true;
                    }
                    else if ("sma" == parameter)
                    {
                        this.suppressMsiAssemblyTable = true;
                    }
                    else if ("sf" == parameter)
                    {
                        this.suppressFiles = true;
                    }
                    else if ("sh" == parameter)
                    {
                        this.suppressFileHashAndInfo = true;
                    }
                    else if (parameter.StartsWith("sice:"))
                    {
                        this.suppressICEs.Add(parameter.Substring(5));
                    }
                    else if ("sl" == parameter)
                    {
                        this.suppressLayout = true;
                    }
                    else if ("ss" == parameter)
                    {
                        this.suppressSchema = true;
                    }
                    else if ("sui" == parameter)
                    {
                        this.suppressUISequence = true;
                    }
                    else if ("sv" == parameter)
                    {
                        this.suppressVersionCheck = true;
                    }
                    else if ("sval" == parameter)
                    {
                        this.suppressValidation = true;
                    }
                    else if (parameter.StartsWith("sw"))
                    {
                        try
                        {
                            int suppressWarning = Convert.ToInt32(parameter.Substring(2), CultureInfo.InvariantCulture.NumberFormat);

                            if (0 >= suppressWarning)
                            {
                                this.messageHandler.Display(this, WixErrors.IllegalSuppressWarningId(parameter.Substring(2)));
                            }

                            this.messageHandler.SuppressWarningMessage(suppressWarning);
                        }
                        catch (FormatException)
                        {
                            this.messageHandler.Display(this, WixErrors.IllegalSuppressWarningId(parameter.Substring(2)));
                        }
                        catch (OverflowException)
                        {
                            this.messageHandler.Display(this, WixErrors.IllegalSuppressWarningId(parameter.Substring(2)));
                        }
                    }
                    else if ("ts" == parameter)
                    {
                        this.sectionIdOnRows = true;
                    }
                    else if ("tsa" == parameter)
                    {
                        this.sectionIdOnRows    = true;
                        this.generateSectionIds = true;
                    }
                    else if ("v" == parameter)
                    {
                        this.messageHandler.ShowVerboseMessages = true;
                    }
                    else if ("wx" == parameter)
                    {
                        this.messageHandler.WarningAsError = true;
                    }
                    else if ("xo" == parameter)
                    {
                        this.outputXml                    = true;
                        this.sectionIdOnRows              = true;
                        this.generateSectionIds           = true;
                        this.suppressDroppingUnrealTables = true;
                    }
                    else if ("?" == parameter || "help" == parameter)
                    {
                        this.showHelp = true;
                    }
                }
                else if ('@' == arg[0])
                {
                    this.ParseCommandLine(AppCommon.ParseResponseFile(arg.Substring(1)));
                }
                else
                {
                    this.inputFiles.AddRange(AppCommon.GetFiles(arg, "Source"));
                }
            }

            if (this.bindFiles && !this.outputXml)
            {
                throw new ArgumentException("The -bf (bind files) option is only applicable with the -xo (xml output) option.");
            }
        }