Workspaces are immutable. This means that any method that sounds as if it is going to change the workspace will instead return a new instance with the changes made.
So you want something like:
IWorkspace workspace = Workspace.LoadSolution("MySolution.sln"); var originalSolution = workspace.CurrentSolution; var project = originalSolution.GetProject(originalSolution.ProjectIds.First()); IDocument doc = project.AddDocument("index.html", "<html></html>"); workspace.ApplyChanges(originalSolution, doc.Project.Solution);
However, I am not near the Roslyn machine currently installed, so I cannot guarantee it is 100%.
Damien_The_Unbeliever
source share