コード例 #1
0
        public static void Main(string[] args)
        {
            DateTime startTime = DateTime.UtcNow;

            CommandLineUtils.PrintInfoMessage("Plugin is running... ");
            projectPath = args[0];
            DirectoryInfo projectDir = new DirectoryInfo(projectPath);

            CommandLineUtils.PrintInfoMessage($"Project Name: {projectDir.Name}");
            string nugetFile = Path.Combine(projectPath, packagesFile);

            if (TryGetPolicy(out ProjectPolicy policy))
            {
                if (File.Exists(nugetFile))
                {
                    CommandLineUtils.PrintInfoMessage("Finding project dependencies...  ");
                    List <NuGetPackage> packagesFound = PackageLoader.LoadPackages(nugetFile)
                                                        .Where(package => package.Id != pluginId)
                                                        .ToList();
                    CommandLineUtils.PrintSuccessMessage("Finding project dependencies DONE");
                    CommandLineUtils.PrintInfoMessage("Searching for dependencies licenses and vulnerabilities...  ");
                    List <Dependency> dependenciesEvaluated = ValidateProjectDependencies(packagesFound, policy).Result;
                    CommandLineUtils.PrintSuccessMessage("Searching for dependencies licenses and vulnerabilities DONE");
                    string report = GenerateReport(dependenciesEvaluated, policy);
                    CommandLineUtils.PrintSuccessMessage("Produced report locally.");
                    StoreReport(report);
                    double seconds = (DateTime.UtcNow - startTime).TotalSeconds;
                    CommandLineUtils.PrintInfoMessage("Plugin execution time: " + seconds);
                }
                else
                {
                    CommandLineUtils.PrintErrorMessage($"Packages.config file not found in project {projectDir.Name}");
                }
            }
        }