// recursive function private void Parse(DirectoryInfo rootDirectory, String relativePath, RelativeReference relativeReference, ref Dictionary<SystemReference, IList<RelativeReference>> references) { String currentPath = Path.Combine(rootDirectory.FullName, relativePath); SystemReference systemReference = null; var modifiedPath = Regex.Replace(relativeReference.ReferenceName, "^~/", "/"); var referenceIsAbsolutePath = !string.IsNullOrEmpty(relativeReference.ReferenceName) && (modifiedPath[0] == '/'); var filePath = referenceIsAbsolutePath ? Path.Combine(rootDirectory.FullName, modifiedPath.Substring(1)) : Path.Combine(currentPath, relativeReference.ReferenceName); var fileReference = new FileInfo(filePath); // Doesn't really exist, just create the system reference and return if (relativeReference.Type == Reference.TypeEnum.Generated) { systemReference = new SystemReference(rootDirectory, fileReference, relativeReference.ReferenceName) { Type = relativeReference.Type }; relativeReference.UpdateFromSystemReference(systemReference); if (!references.ContainsKey(systemReference)) { references.Add(systemReference, new List<RelativeReference>()); } return; } if (fileReference.Exists) { systemReference = new SystemReference(rootDirectory, fileReference, relativeReference.ReferenceName) { Type = relativeReference.Type }; } if (systemReference == null) { throw new FileNotFoundException(String.Format("Unable to find the file: '{0}' in the current path: '{1}'.", relativeReference.Name, filePath)); } relativeReference.UpdateFromSystemReference(systemReference); // We check for library references here rather than below, because we have the actual file path now if (relativeReference.Type == Reference.TypeEnum.Library) { if (!references.ContainsKey(systemReference)) { references.Add(systemReference, new List<RelativeReference>()); } return; } var newRelativeReferences = GetReferences(systemReference, ref references); foreach (var reference in newRelativeReferences) { Parse(rootDirectory, systemReference.Path, reference, ref references); } }