Example #1
0
        private void ProcessArguments(string[] args)
        {
            optionSet = new OptionSet
            {
                { "t|target=", "{NAME} of a target project (repeat for multiple targets)",
                  v => options.TargetProjectNames.Add(v) },
                { "r|root=", "{PATH} to the root directory where your projects reside (optional, defaults to working directory)",
                  v => options.ProjectsRootDirectory = v },
                { "l|narrow=", "limit search process to {PATH}(s) in the root directory (optional, repeat for multiple paths)",
                  v => options.AddRootFolderSearchPaths(v) },
                { "s|search=", "additional {PATH}(s) to search for projects to include outside of the root directory (repeat for multiple paths)",
                  v => options.AddAdditionalSearchPaths(v) },
                { "i|ignore=", "ignore directories whose name matches the given {REGEX_PATTERN} (repeat for multiple ignores)",
                  v => options.AddIgnoreDirectoryPatterns(v) },
                { "o|out=", "directory {PATH} where you want the .sln file written",
                  v => options.SlnOutputPath = v },
                { "version=", "Visual Studio {VERSION} compatibility (2008, 2010, 2012, 2013, 2015, 2017, 2019, default)",
                  v => options.VisualStudioVersion = TryParseVersionNumber(v) },
                { "p|projecttype=", "Project file {TYPE} ('.csproj', '.vbproj', '.vcxproj', default)",
                  v => options.AddProjectFileTypes(TryParseProjectType(v)) },
                { "n|name=", "alternate {NAME} for solution file",
                  v => options.SolutionName = v },
                { "m|minimal", "skip all afferent assembly references (included by default)",
                  v => options.SkipAfferentAssemblyReferences = true },
                { "a|all", "include all efferent assembly references (omitted by default)",
                  v => options.IncludeEfferentAssemblyReferences = true },
                { "h|help", "display the help screen",
                  v => options.ShowHelp = true },
                { "c|convert", "convert assembly references in csproj files to project references",
                  v => options.ConvertReferences = true },
                { "u|unconvert", "unconvert (restore) assembly references that were previously converted",
                  v => options.RestoreReferences = true },
                { "H|fixhintpaths", "convert hint paths in csproj files to point to nuget packages folder relative to generated sln",
                  v => options.FixHintPaths = true },
                { "U|restorehintpaths", "unconvert hint paths in csproj files to point to their original nuget packages folder",
                  v => options.RestoreHintPaths = true },
                { "open", "open the solution in Visual Studio",
                  v => options.OpenInVisualStudio = true },
                { "debug", "attach debugger",
                  v => Debugger.Launch() },
                { "q|quiet", "reduce logging verbosity (can specify multiple times)",
                  v => options.LoggingThreshold = options.LoggingThreshold.DecreaseVerbosity() },
                { "v|verbose", "increase logging verbosity (can specify multiple times)",
                  v => options.LoggingThreshold = options.LoggingThreshold.IncreaseVerbosity() }
            };

            try
            {
                optionSet.Parse(args);
            }
            catch (OptionException optEx)
            {
                if (ParseError != null)
                {
                    ParseError(optEx.Message);
                }
            }
        }