我正在尝试用Roslyn做基本的事情,但真的很难。我试图将项目添加到解决方案中时遇到困难 - 当我尝试将项目添加到解决方案/工作区时,它不适用并且项目计数保持为零。
这是我目前的代码。我怎么搞砸这么基本的东西?
var workspace = new CustomWorkspace(MefHostServices.DefaultHost);
var project = workspace.CurrentSolution.AddProject("[name]", "__assemblyName__", LanguageNames.CSharp);
workspace.TryApplyChanges(project.Solution); // i have tried it with and without this line
var projectCount = workspace.CurrentSolution.Projects.Count(); // is still zero