public static IEnumerable <string> GetFiles(string rootDirectory, string configFilePath, out List <string> startFiles) { var list = new List <string>(); startFiles = new List <string>(); IncludeExcludePattern includeExclude = null; bool isRootFile = false; if (File.Exists(configFilePath)) { includeExclude = IncludeExcludePattern.ParseFromFile(configFilePath); } if (File.Exists(rootDirectory)) { isRootFile = true; startFiles.Add(Path.GetFullPath(rootDirectory)); rootDirectory = Path.GetDirectoryName(rootDirectory); } foreach (var file in Directory.GetFiles(rootDirectory, "*", SearchOption.AllDirectories)) { if (!file.EndsWith(".dll", StringComparison.OrdinalIgnoreCase) && !file.EndsWith(".exe", StringComparison.OrdinalIgnoreCase) && !file.EndsWith(".exe.config", StringComparison.OrdinalIgnoreCase)) { continue; } var relativeFilePath = file.Substring(rootDirectory.Length); if (file.EndsWith(".exe.config", StringComparison.OrdinalIgnoreCase)) { if (includeExclude != null && includeExclude.Includes(relativeFilePath)) { list.Add(Path.GetFullPath(file)); } continue; } if (includeExclude == null || !includeExclude.Excludes(relativeFilePath)) { if (PEFile.IsManagedAssembly(file)) { var filePath = Path.GetFullPath(file); list.Add(filePath); if (!isRootFile) { startFiles.Add(filePath); } } } } return(list); }
public static IEnumerable <string> GetFiles(string rootDirectory, string configFilePath, string pattern = "*.dll") { var list = new List <string>(); IncludeExcludePattern includeExclude = null; if (File.Exists(configFilePath)) { includeExclude = IncludeExcludePattern.ParseFromFile(configFilePath); } foreach (var file in Directory.GetFiles(rootDirectory, pattern, SearchOption.AllDirectories)) { if (includeExclude == null || includeExclude.Includes(file)) { list.Add(file); } } return(list); }