Пример #1
0
        private ProjectGenerator CreateGenerator()
        {
            string solutionPath = GetPropertyValue(PARAM_KEY_SOLUTION);

            if (string.IsNullOrWhiteSpace(solutionPath))
            {
                Console.WriteLine("Searching for a solution file to process...");
                // search for solution
                string   currentDirectory = Directory.GetCurrentDirectory();
                string[] solutionPaths    = Directory.GetFiles(currentDirectory, "*.sln");

                if (solutionPaths != null && solutionPaths.Length >= 1)
                {
                    SolutionGenerator solutionGenerator = new SolutionGenerator();
                    solutionGenerator.SolutionPath       = solutionPaths[0];
                    solutionGenerator.GenerateMergedBdio = Convert.ToBoolean(GetPropertyValue(PARAM_KEY_HUB_CREATE_MERGED_BDIO, "false"));
                    PropertyMap[PARAM_KEY_SOLUTION]      = solutionPaths[0];
                    return(solutionGenerator);
                }
                else
                {
                    Console.WriteLine("No Solution file found.  Searching for a project file...");
                    string[] projectPaths = Directory.GetFiles(currentDirectory, "*.csproj");
                    if (projectPaths != null && projectPaths.Length > 0)
                    {
                        string projectPath = projectPaths[0];
                        Console.WriteLine("Found project {0}", projectPath);
                        ProjectGenerator projectGenerator = new ProjectGenerator();
                        projectGenerator.ProjectPath = projectPath;
                        return(projectGenerator);
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
            else
            {
                if (solutionPath.Contains(".sln"))
                {
                    SolutionGenerator solutionGenerator = new SolutionGenerator();
                    solutionGenerator.SolutionPath = solutionPath;

                    return(solutionGenerator);
                }
                else
                {
                    ProjectGenerator projectGenerator = new ProjectGenerator();
                    projectGenerator.ProjectPath = solutionPath;
                    return(projectGenerator);
                }
            }
        }
Пример #2
0
        private void ConfigureGenerator(OptionSet commandOptions)
        {
            ResolveProperties();
            ProjectGenerator = CreateGenerator();

            if (ProjectGenerator == null)
            {
                ShowHelpMessage("Couldn't find a solution or project. Usage buildBom.exe [OPTIONS]", commandOptions);
            }

            if (PropertyMap.ContainsKey(PARAM_KEY_HUB_OUTPUT_DIRECTORY))
            {
                if (String.IsNullOrWhiteSpace(PropertyMap[PARAM_KEY_HUB_OUTPUT_DIRECTORY]))
                {
                    string currentDirectory       = Directory.GetCurrentDirectory();
                    string defaultOutputDirectory = $"{currentDirectory}{Path.DirectorySeparatorChar}{ProjectGenerator.DEFAULT_OUTPUT_DIRECTORY}";
                    PropertyMap[PARAM_KEY_HUB_OUTPUT_DIRECTORY] = defaultOutputDirectory;
                }
            }

            LogProperties();

            ProjectGenerator.Verbose         = Verbose;
            ProjectGenerator.HubUrl          = GetPropertyValue(PARAM_KEY_HUB_URL);
            ProjectGenerator.HubUsername     = GetPropertyValue(PARAM_KEY_HUB_USERNAME);
            ProjectGenerator.HubPassword     = GetPropertyValue(PARAM_KEY_HUB_PASSWORD);
            ProjectGenerator.PackagesRepoUrl = GetPropertyValue(PARAM_KEY_PACKAGE_REPO_URL);

            ProjectGenerator.HubTimeout     = Convert.ToInt32(GetPropertyValue(PARAM_KEY_HUB_TIMEOUT, "120"));
            ProjectGenerator.HubProjectName = GetPropertyValue(PARAM_KEY_HUB_PROJECT_NAME);
            ProjectGenerator.HubVersionName = GetPropertyValue(PARAM_KEY_HUB_VERSION_NAME);

            ProjectGenerator.HubProxyHost     = GetPropertyValue(PARAM_KEY_HUB_PROXY_HOST);
            ProjectGenerator.HubProxyPort     = GetPropertyValue(PARAM_KEY_HUB_PROXY_PORT);
            ProjectGenerator.HubProxyUsername = GetPropertyValue(PARAM_KEY_HUB_PROXY_USERNAME);
            ProjectGenerator.HubProxyPassword = GetPropertyValue(PARAM_KEY_HUB_PROXY_PASSWORD);

            ProjectGenerator.HubScanTimeout           = Convert.ToInt32(GetPropertyValue(PARAM_KEY_HUB_SCAN_TIMEOUT, "300"));
            ProjectGenerator.OutputDirectory          = GetPropertyValue(PARAM_KEY_HUB_OUTPUT_DIRECTORY);
            ProjectGenerator.ExcludedModules          = GetPropertyValue(PARAM_KEY_EXCLUDED_MODULES);
            ProjectGenerator.HubIgnoreFailure         = Convert.ToBoolean(GetPropertyValue(PARAM_KEY_HUB_IGNORE_FAILURE, "false"));
            ProjectGenerator.CreateFlatDependencyList = Convert.ToBoolean(GetPropertyValue(PARAM_KEY_HUB_CREATE_FLAT_LIST, "false"));
            ProjectGenerator.CreateHubBdio            = Convert.ToBoolean(GetPropertyValue(PARAM_KEY_HUB_CREATE_BDIO, "true"));
            ProjectGenerator.DeployHubBdio            = Convert.ToBoolean(GetPropertyValue(PARAM_KEY_HUB_DEPLOY_BDIO, "true"));
            ProjectGenerator.CreateHubReport          = Convert.ToBoolean(GetPropertyValue(PARAM_KEY_HUB_CREATE_REPORT, "false"));
            ProjectGenerator.CheckPolicies            = Convert.ToBoolean(GetPropertyValue(PARAM_KEY_HUB_CHECK_POLICIES, "false"));
            ProjectGenerator.HubCodeLocationName      = GetPropertyValue(PARAM_KEY_HUB_CODE_LOCATION_NAME);
        }