static void RunRepoImporter() { var targetIndexName = AnalysisServices.GetTargetIndexName(repoName); string[] file = new string[0]; bool requireProjectsExist = true; string assembly = null; if (File.Exists(rootDirectory)) { if (rootDirectory.EndsWith(".dll", StringComparison.OrdinalIgnoreCase) || rootDirectory.EndsWith(".exe", StringComparison.OrdinalIgnoreCase)) { assembly = rootDirectory; } file = new[] { rootDirectory }; rootDirectory = Path.GetDirectoryName(rootDirectory); requireProjectsExist = false; } Directory.CreateDirectory("output"); using (StreamWriter writer = new StreamWriter(@"output\log.txt")) { Logger logger = new MultiLogger( new ConsoleLogger(), new TextLogger(TextWriter.Synchronized(writer))); FileSystem fileSystem = new CachingFileSystem( new UnionFileSystem(file.Union(Enumerable.Repeat(solutionPath, String.IsNullOrEmpty(solutionPath) ? 0 : 1)), new RootFileSystem(rootDirectory, new MultiFileSystemFilter( new DirectoryFileSystemFilter(@"\.", ".sln"), new GitIgnoreFilter(), new BinaryFileSystemFilter(new string[] { ".exe", ".dll", "*.blob", ".db" }) )) { DisableEnumeration = file.Length != 0 })); List <RepoProjectAnalyzer> projectAnalyzers = new List <RepoProjectAnalyzer>() { //new MSBuildSolutionProjectAnalyzer() new BinLogSolutionProjectAnalyzer() { RequireProjectFilesExist = requireProjectsExist } }; if (assembly != null) { fileSystem = new FileSystem(); projectAnalyzers.Clear(); projectAnalyzers.Add(new MetadataAsSourceProjectAnalyzer(file)); } IAnalysisTarget analysisTarget = null; if (analysisOnly) { analysisTarget = new NullAnalysisTarget(); } else { ElasticsearchStorage storage = GetStorage(); logger.WriteLine("Removing repository"); ((IStorage)storage).RemoveRepository(targetIndexName).GetAwaiter().GetResult(); logger.WriteLine("Removed repository"); analysisTarget = storage; } RepositoryImporter importer = new RepositoryImporter(repoName, rootDirectory, new AnalysisServices( targetIndexName, fileSystem, analyzers: new RepoFileAnalyzer[] { new SolutionFileAnalyzer(), new MSBuildFileAnalyzer(), new XmlFileAnalyzer( ".ds", ".xml", ".config", ".settings"), }) //new ExternalRepoFileAnalyzer(new[] { @"d:\temp\Codex" }), // This indexer allows an external tool to write out codex spans for importing. We sill need to add support for a 'marker' file so we don't have to pass a folder. { AnalysisTarget = analysisTarget, Logger = logger, }) { AnalyzerDatas = projectAnalyzers.Select(a => new AnalyzerData() { Analyzer = a }).ToList() }; importer.Import(finalizeImport: finalize).GetAwaiter().GetResult(); } }
static void RunRepoImporter(params string[] args) { string repoName = args[0]; string rootDirectory = args[1]; var targetIndexName = AnalysisServices.GetTargetIndexName(repoName); string[] file = new string[0]; bool requireProjectsExist = true; string assembly = null; if (File.Exists(rootDirectory)) { if (rootDirectory.EndsWith(".dll", StringComparison.OrdinalIgnoreCase) || rootDirectory.EndsWith(".exe", StringComparison.OrdinalIgnoreCase)) { assembly = rootDirectory; } file = new[] { rootDirectory }; rootDirectory = Path.GetDirectoryName(rootDirectory); requireProjectsExist = false; } Directory.CreateDirectory("output"); using (StreamWriter writer = new StreamWriter(@"output\log.txt")) { Logger logger = new MultiLogger( new ConsoleLogger(), new TextLogger(TextWriter.Synchronized(writer))); FileSystem fileSystem = new CachingFileSystem( new UnionFileSystem(file.Union(args.Skip(2)), new RootFileSystem(rootDirectory, new MultiFileSystemFilter( new DirectoryFileSystemFilter(@"\.", ".sln"), new GitIgnoreFilter(), new BinaryFileSystemFilter(new string[] { ".exe", ".dll", "*.blob", ".db" }) )) { DisableEnumeration = file.Length != 0 })); List <RepoProjectAnalyzer> projectAnalyzers = new List <RepoProjectAnalyzer>() { new MSBuildSolutionProjectAnalyzer() //new ManagedSolutionProjectAnalyzer() { RequireProjectFilesExist = requireProjectsExist } }; if (assembly != null) { fileSystem = new FileSystem(); projectAnalyzers.Clear(); projectAnalyzers.Add(new MetadataAsSourceProjectAnalyzer(file)); } IAnalysisTarget analysisTarget = null; if (analysisOnly) { analysisTarget = new NullAnalysisTarget(); } else { ElasticsearchStorage storage = new ElasticsearchStorage(url); logger.WriteLine("Removing repository"); ((IStorage)storage).RemoveRepository(targetIndexName).GetAwaiter().GetResult(); logger.WriteLine("Removed repository"); analysisTarget = storage; } RepositoryImporter importer = new RepositoryImporter(repoName, rootDirectory, new AnalysisServices( targetIndexName, fileSystem, analyzers: new RepoFileAnalyzer[] { new SolutionFileAnalyzer(), new MSBuildFileAnalyzer(), new XmlFileAnalyzer( ".ds", ".xml", ".config", ".settings"), }) { AnalysisTarget = analysisTarget, Logger = logger, }) { AnalyzerDatas = projectAnalyzers.Select(a => new AnalyzerData() { Analyzer = a }).ToList() }; importer.Import(finalizeImport: finalize).GetAwaiter().GetResult(); } }