Roslyn加载项目文档失败 [英] Roslyn load project documents failing

查看:120
本文介绍了Roslyn加载项目文档失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Visual Studio扩展(VSIX)解决方案中,我使用Roslyn从当前解决方案中加载特定项目:

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")

项目myProject肯定已加载,但是在检查中我看到:

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

myProject.HasDocuments == false
myProject.Documents is Empty

但是,在Visual Studio中,我可以看到大量的文档.

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

如果我关闭解决方案并从另一个TFS分支中打开相同的解决方案,则返回相同的代码:

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

有什么想法吗?

推荐答案

我可以通过以下方法来工作:

I got this to work by:

  1. 删除obj/debug文件夹
  2. 清洁
  3. 转换所有T4模板(这是ASP.NET MVC)
  4. 重新启动Visual Studio
  5. 重新编译

仅重新编译无效.无法解释原因,但是上面的公式对我有用.

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

这篇关于Roslyn加载项目文档失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆