You can load the solution by using Roslyn.Services.Workspace.LoadSolution. Once you have done so, you need to go through each of the projects in dependency order, get the Compilation for the project and call Emit on it.
You can get the compilations in dependency order with code like below. (Yes, I know that having to cast to IHaveWorkspaceServices sucks. It'll be better in the next public release, I promise).
static void Main(string args)
var solution = Solution.Create(SolutionId.CreateNewId()).AddCSharpProject("Foo", "Foo").Solution;
var workspaceServices = (IHaveWorkspaceServices)solution;
var projectDependencyService = workspaceServices.WorkspaceServices.GetService<IProjectDependencyService>();
var assemblies = new List<Stream>();
foreach (var projectId in projectDependencyService.GetDependencyGraph(solution).GetTopologicallySortedProjects())
using (var stream = new MemoryStream())
Note1: LoadSolution still does use msbuild under the covers to parse the .csproj files and determine the files/references/compiler options.
Note2: As Roslyn is not yet language complete, there will likely be projects that don't compile successfully when you attempt this.
Is there a convenient way of determining the dependency order (like sln.ProjectsInDependencyOrder) or is this something I would have to implement on my own? (e.g. Going through project-references and building a dependency tree)
There is an IProjectDependencyService that has GetTopologicallySortedProjects(). I don't have a computer handy to check exactly how to get it, but will update later.
This solution doesn't work in the current preview 1.0.0-beta1-20141031-01. Roslyn.Services.Workspace.LoadSolution() doesn't exist, neither does Solution.Create(). I think you have to use MSBuildWorkspace.Create along with OpenSolutionAsync (for existing sln) or just workspace.CurrentSolution for empty one. As well, you'll need to install the MSBuild 2015 tools from microsoft.com/en-us/download/details.aspx?id=44931 in order to use an MSBuildWorkspace. Or, you can MEF export a catalog and use CustomWorkspace. The whole process has gotten much more complicated it seems
To add to @JoshE's comment, the Solution class now has a GetProjectDependencyGraph method that does all of this, once you have the Solution object.