Example #1
0
        protected static void AddIndirectReferences(IProjectFinder projectFinder, Regex[] assemblyNamePatterns, bool ignoreOnlyMatching,
                                                    HashSet <string> originalAssemblyReferenceNames, Queue <AssemblyReference> remainingReferences, string targetPath,
                                                    Project buildingProject, FileInfo[] projectOutputs, string explicitTargetPath, AssemblyReference assemblyReference,
                                                    List <IndirectReferenceInfo> indirectReferencesOutsideSolution)
        {
            var indirectReferences = GetIndirectReferences(originalAssemblyReferenceNames, targetPath, projectOutputs, explicitTargetPath)
                                     .Where(x => IncludeAssemblyWhenCopyingDeps(x, assemblyNamePatterns, ignoreOnlyMatching))
                                     .ToArray();

            if (false == indirectReferences.Any())
            {
                return;
            }
            var buildingSolution = projectFinder.GetSLNFileForProject(buildingProject);

            // TODO: Print the name of the project that is missing these indirect references instead of letting the user guess.
            _logger.InfoFormat("Adding indirect references listed below. The direct reference is to {0}.\n{1}\nThis probably means some project is referencing {0} but does not reference all of the listed indirect assemblies above.\nHere's a list of projects referencing {0}:\n{2}",
                               assemblyReference.Name, StringExtensions.Tabify(indirectReferences.Select(x => x.Name)),
                               StringExtensions.Tabify(ProjectsUsingAssemblyReference(projectFinder, assemblyReference)));
            foreach (var indirectReference in indirectReferences)
            {
                var indirectReferenceBuildingProject = projectFinder.FindProjectForAssemblyReference(indirectReference).SingleOrDefault();
                var indirectReferenceInfo            = new IndirectReferenceInfo(assemblyReference, buildingProject, indirectReference, indirectReferenceBuildingProject);
                if (null != indirectReferenceBuildingProject)
                {
                    if (projectFinder.GetSLNFileForProject(indirectReferenceBuildingProject).FullName.Equals(buildingSolution.FullName, StringComparison.InvariantCultureIgnoreCase))
                    {
                        originalAssemblyReferenceNames.Add(ComparableAssemblyName(indirectReference));
                        remainingReferences.Enqueue(indirectReference);
                        continue;
                    }
                }
                indirectReferencesOutsideSolution.Add(indirectReferenceInfo);
            }
        }
 private static string SLNVertexName(IProjectFinder projectFinder, Project project)
 {
     return(projectFinder.GetSLNFileForProject(project).FullName);
 }
 protected static IEnumerable <Project> GetAllProjectsInSolutionsOfProject(IProjectFinder projectFinder, Project project)
 {
     return(projectFinder.GetProjectsOfSLN(projectFinder.GetSLNFileForProject(project)));
 }