Roslyn load project documents failing

 ̄綄美尐妖づ 提交于 2019-12-08 17:28:43

问题


In a Visual Studio Extension (VSIX) solution, I'm using Roslyn to load a specific project from my current solution:

Project myProject = 
    this.CurrentComponentModel.GetService<VisualStudioWorkspace>()
        .CurrentSolution.Projects
             .FirstOrDefault(p => p.Name == "MyProject")

The projct myProject is definitely loaded, but on inspection I see that:

myProject.HasDocuments == false
myProject.Documents is Empty

And yet, in Visual Studio I can see loads of documents.

If I close the solution and open the same solution but from another TFS branch, then the same code returns:

myProject.HasDocuments == true 
myProject.Documents is not Empty

Any ideas?


回答1:


I got this to work by:

  1. Deleting the obj/debug folder
  2. Cleaning
  3. Transforming all T4 templates (this is ASP.NET MVC)
  4. Restarting Visual Studio
  5. Re-compiling

Simply re-compiling had no effect. Can't explain why, but the above formula worked for me.



来源:https://stackoverflow.com/questions/37731013/roslyn-load-project-documents-failing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!