Example #1
0
        public static bool Initiate(string projectPath, string trustSourceUserName, string trustSourceApiKey, string trustSourceApiUrl = "")
        {
            var    dependencyGraphService = new DependencyGraphService();
            var    dependencyGraph        = dependencyGraphService.GenerateDependencyGraph(projectPath);
            string solutionName           = VisualStudioProvider.GetSolutionName(projectPath);

            foreach (var project in dependencyGraph.Projects)
            {
                Target projectTarget = null;

                if (project.RestoreMetadata.ProjectStyle == ProjectStyle.PackageReference)
                {
                    // Process Project Dependencies
                    projectTarget = NetCoreScannerExcecuter.ProcessDependencies(solutionName, project);
                }
                else
                {
                    projectTarget = NetFrameWorkScannerExecutor.ProcessDependencies(solutionName, project);
                }

                // Convert Target into Json string
                string targetJson = TargetSerializer.ConvertToJson(projectTarget);

                // Finally Post Json to Trust Source server
                TrustSourceProvider.PostScan(targetJson, trustSourceUserName, trustSourceApiKey, trustSourceApiUrl);
            }

            return(true);
        }
Example #2
0
        public static List <Target> Execute(string projectPath, string tsBranch, string tsTag)
        {
            var targets = new List <Target>();

            var dependencyGraphService = new DependencyGraphService();
            var dependencyGraph        = dependencyGraphService.GenerateDependencyGraph(projectPath);

            if (dependencyGraph != null)
            {
                string solutionName = VisualStudioProvider.GetSolutionName(projectPath);

                foreach (var project in dependencyGraph.Projects)
                {
                    Target projectTarget;

                    if (project.RestoreMetadata.ProjectStyle == ProjectStyle.PackageReference)
                    {
                        // Process Project Dependencies
                        projectTarget = NetCoreScannerExcecuter.ProcessDependencies(solutionName, project);
                    }
                    else
                    {
                        projectTarget = NetFrameWorkScannerExecutor.ProcessDependencies(solutionName, project, projectPath);
                    }

                    projectTarget.branch = tsBranch;
                    projectTarget.tag    = tsTag;

                    targets.Add(projectTarget);
                }
            }

            return(targets);
        }