Ejemplo n.º 1
0
        private static IDictionary <string, string> _GetProjectDependencies(XDocument projXml, string projectPath)
        {
            Dictionary <string, string> projectDependencies = new Dictionary <string, string>();

            IEnumerable <XElement> projectReferenceNodes = MSBuildUtilities.GetProjectReferenceNodes(projXml);

            foreach (XElement projectReferenceNode in projectReferenceNodes)
            {
                string dependentProjectGuid   = MSBuildUtilities.GetProjectReferenceGUID(projectReferenceNode, projectPath);
                string relativePathToProject  = MSBuildUtilities.GetProjectReferenceIncludeValue(projectReferenceNode, projectPath);
                string pathToDependentProject = PathUtilities.ResolveRelativePath(projectPath, relativePathToProject);

                if (projectDependencies.ContainsKey(dependentProjectGuid))
                {
                    string message = $"Guid `{dependentProjectGuid}` is duplicated in project `{projectPath}`";
                    throw new InvalidOperationException(message);
                }
                else
                {
                    projectDependencies.Add(dependentProjectGuid, pathToDependentProject);
                }
            }

            return(projectDependencies);
        }