static async Task Main(string[] args) { // Attempt to set the version of MSBuild. var visualStudioInstances = MSBuildLocator.QueryVisualStudioInstances().ToArray(); var instance = visualStudioInstances.Length == 1 // If there is only one instance of MSBuild on this machine, set that as the one to use. ? visualStudioInstances[0] // Handle selecting the version of MSBuild you want to use. : SelectVisualStudioInstance(visualStudioInstances); Console.WriteLine($"Using MSBuild at '{instance.MSBuildPath}' to load projects."); // NOTE: Be sure to register an instance with the MSBuildLocator // before calling MSBuildWorkspace.Create() // otherwise, MSBuildWorkspace won't MEF compose. MSBuildLocator.RegisterInstance(instance); var projectPath = args[0]; documentation = new Documentation(projectPath); var properties = new Dictionary <string, string> { { "Configuration", "Debug" }, }; using (var workspace = MSBuildWorkspace.Create(properties)) { // Print message for WorkspaceFailed event to help diagnosing project load failures. workspace.WorkspaceFailed += (o, e) => Console.WriteLine(e.Diagnostic.Message); Console.WriteLine($"Loading solution '{projectPath}'"); // Attach progress reporter so we print projects as they are loaded. var solution = await workspace.OpenSolutionAsync(projectPath, new ConsoleProgressReporter()); Console.WriteLine($"Finished loading solution '{projectPath}'"); foreach (var project in solution.Projects) { var compilation = await project.GetCompilationAsync(); foreach (var document in project.Documents) { var syntaxTree = await document.GetSyntaxTreeAsync(); var syntaxRoot = await syntaxTree.GetRootAsync(); IterateSyntaxNode(compilation, syntaxTree, syntaxRoot); } } DiskProvider.Save(args[1], documentation.Namespaces.Values.ToList()); // TODO: Do analysis on the projects in the loaded solution } }